c# pd.PrintPage += new PrintPageEvenbeanlisthandlerr(this.pd_PrintPage); 这么写什么意思,就是加载事件么

扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
c#打印原理
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口热线电话 028-
ZPL命令通过USB接口发送到斑马ZM400的简单实现方法!
点击数:1014 13:19:50 来源:
在现代条码打印机的商业使用中采用向并口或串口传送指令的方式运用越来越少,条码机厂商都选择了
方便,灵活,速度传输更快的USB接口来接收编程命令。在程序开发方面就牵涉到如何通过USB接口来传输
相关编程命令的问题。
解决方法有多种多样,首先要明确的是我们不能像调用LPT1和COM1口那样去调用虚拟的USB1口,那我们从
中选择一种最简单的方法来解决USB接口传输的问题,我们以斑马的ZM400&300dpi为例子,首先正确安装斑
马打印机机驱动,设置此ZM400为默认打印机,安装成功后在设备里虚拟出一个USB1,。最后使用C#调用默认
打印机的方式,把需要发送的ZPL打印命令赋值给一个变量,并存入相关文件,最后用C#调用打印机来打印
这个文件。在这种解决方案中就不用考虑如何通过USB传输的问题,都交给驱动程序来解决,在打印时系统会
自动通过usb端口传输EPL到默认打印机。
下面附上使用C#的实现代码:
&&PrintDocument&printDocument&=&new&PrintDocument();
&&printDocument.PrintPage&+=&new&PrintPageEventHandler(this.pd_PrintPage);
&&printDocument.Print();
&&private&void&pd_PrintPage(object&sender,&PrintPageEventArgs&e)
&&Font&mainFont&=&new&Font("Courier&New",&8);
&&string&strLine&=&String.Format("{0,0}",&&Gb.printstr);//Gb.printstr包含ZPL指令的全局变量
&&e.Graphics.DrawString(strLine,&mainFont,&Brushes.Black,&PointF.Empty);
【责任编辑:】
成都吉菲科呈电子-专业条码打印机服务商 24小时客户热线:
版权所有(C)2013 成都吉菲科呈电子 蜀ICP备号printdocument.print在asp.net中如何使用_百度知道
printdocument.print在asp.net中如何使用
catch(Exception ex)
MessageBox.Close();
/My Documents&#92, new StringFormat()).
linesPerPage =
float leftMargin =
/&#47.MarginBounds.net里printdocument在服务器端打印&#47, printF&#47首先;Arial&quot.ReadLine()) != null))
yPos = topMargin + (count *
printF linesPerPage &&
((line=streamToPrint!= null)
int count = 0; The PrintPage event is raised for each page to be printed, Brushes.Graphics).L&#92, asp.GetHeight(ev, EventArgs e)
streamToPrint = new StreamReader
if(line :&#92.MarginBC,
string line =
&#47.Show(ex.pd_PrintPage);
float yPos = 0.Print();MyF
printFont.Message);
private void printButton_Click(object sender.txt& Print e
float topMargin =), 10);
printFont = new Font(&quot, yPos.HasMorePages = false.Black.PrintPage += new PrintPageEventHandler
while(count &lt.GetHeight(; If more lines exist.G
PrintDocument pd = new PrintDocument(),
leftMargin.
private void pd_PrintPage(object sender.Height / Calculate the numb
streamToP&#47.DrawString(line, PrintPageEventArgs ev)
float linesPerPage = 0.T The Click event is raised when the user clicks the Print button.HasMorePages =&#92.Graphics))
其他类似问题
printdocument的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁PrintDocument.PrintPage 事件
当需要为当前页打印的输出时发生。
命名空间:System.Drawing.Printing程序集:System.Drawing(在 system.drawing.dll 中)
Visual Basic(声明)
Public Event PrintPage As PrintPageEventHandler
Visual Basic(用法)
Dim instance As PrintDocument
Dim handler As PrintPageEventHandler
AddHandler instance.PrintPage, handler
public event PrintPageEventHandler PrintPage
event PrintPageEventHandler^ PrintPage {
void add (PrintPageEventHandler^ value);
void remove (PrintPageEventHandler^ value);
/** @event */
public void add_PrintPage (PrintPageEventHandler value)
/** @event */
public void remove_PrintPage (PrintPageEventHandler value)
JScript 支持使用事件,但不支持进行新的声明。
若要指定要打印的输出,请使用
中包含的 。例如,若要指定应打印的一行文本,请使用
方法描述该文本。 除了指定输出之外,还可以通过将
属性设置为 true 来指示是否还有更多的页要打印。默认值为 false,表示没有更多要打印的页。还可以通过
来修改单独的页设置,通过将
属性设置为 true 来取消打印作业。若要使用不同的页设置打印文档的每一页,请处理
事件。 若要使事件与事件处理程序相关联,请将
委托的一个实例添加到事件。一旦发生该事件,将调用此事件处理程序。有关用委托处理事件的更多信息,请参见 。
下面的代码示例演示如何处理 PrintPage 事件。 在此示例中使用 、 和
命名空间。
Visual Basic
Public Class PrintingExample
Inherits System.Windows.Forms.Form
Private components As ponentModel.Container
Private printButton As System.Windows.Forms.Button
Private printFont As Font
Private streamToPrint As StreamReader
Public Sub New()
' The Windows Forms Designer requires the following call.
InitializeComponent()
' The Click event is raised when the user clicks the Print button.
Private Sub printButton_Click(sender As Object, e As EventArgs)
streamToPrint = New StreamReader(&C:\My Documents\MyFile.txt&)
printFont = New Font(&Arial&, 10)
Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
pd.Print()
streamToPrint.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
' The PrintPage event is raised for each page to be printed.
Private Sub pd_PrintPage(sender As Object, ev As PrintPageEventArgs)
Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = ev.MarginBounds.Left
Dim topMargin As Single = ev.MarginBounds.Top
Dim line As String = Nothing
' Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
' Print each line of the file.
While count & linesPerPage
line = streamToPrint.ReadLine()
If line Is Nothing Then
Exit While
yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())
count += 1
' If more lines exist, print another page.
If Not (line Is Nothing) Then
ev.HasMorePages = True
ev.HasMorePages = False
' The Windows Forms Designer requires the following procedure.
Private Sub InitializeComponent()
Me.components = New ponentModel.Container()
Me.printButton = New System.Windows.Forms.Button()
Me.ClientSize = New System.Drawing.Size(504, 381)
Me.Text = &Print Example&
printButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
printButton.Location = New System.Drawing.Point(32, 110)
printButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat
printButton.TabIndex = 0
printButton.Text = &Print the file.&
printButton.Size = New System.Drawing.Size(136, 40)
AddHandler printButton.Click, AddressOf printButton_Click
Me.Controls.Add(printButton)
' This is the main entry point for the application.
Public Shared Sub Main()
Application.Run(New PrintingExample())
public class PrintingExample : System.Windows.Forms.Form
private ponentModel.C
private System.Windows.Forms.Button printB
private Font printF
private StreamReader streamToP
public PrintingExample() : base()
// The Windows Forms Designer requires the following call.
InitializeComponent();
// The Click event is raised when the user clicks the Print button.
private void printButton_Click(object sender, EventArgs e)
streamToPrint = new StreamReader
(&C:\\My Documents\\MyFile.txt&);
printFont = new Font(&Arial&, 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler
(this.pd_PrintPage);
pd.Print();
streamToPrint.Close();
catch(Exception ex)
MessageBox.Show(ex.Message);
// The PrintPage event is raised for each page to be printed.
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.L
float topMargin = ev.MarginBounds.T
string line = null;
// Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height /
printFont.GetHeight(ev.Graphics);
// Print each line of the file.
while(count & linesPerPage &&
((line=streamToPrint.ReadLine()) != null))
yPos = topMargin + (count *
printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
// If more lines exist, print another page.
if(line != null)
ev.HasMorePages = true;
ev.HasMorePages = false;
// The Windows Forms Designer requires the following procedure.
private void InitializeComponent()
this.components = new ponentModel.Container();
this.printButton = new System.Windows.Forms.Button();
this.ClientSize = new System.Drawing.Size(504, 381);
this.Text = &Print Example&;
printButton.ImageAlign =
System.Drawing.ContentAlignment.MiddleL
printButton.Location = new System.Drawing.Point(32, 110);
printButton.FlatStyle = System.Windows.Forms.FlatStyle.F
printButton.TabIndex = 0;
printButton.Text = &Print the file.&;
printButton.Size = new System.Drawing.Size(136, 40);
printButton.Click += new System.EventHandler(printButton_Click);
this.Controls.Add(printButton);
// This is the main entry point for the application.
public static void Main(string[] args)
Application.Run(new PrintingExample());
public ref class PrintingExample: public System::Windows::Forms::Form
System::ComponentModel::Container^
System::Windows::Forms::Button^ printB
System::Drawing::Font^ printF
StreamReader^ streamToP
PrintingExample()
// The Windows Forms Designer requires the following call.
InitializeComponent();
// The Click event is raised when the user clicks the Print button.
void printButton_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
streamToPrint = gcnew StreamReader( &C:\\My Documents\\MyFile.txt& );
printFont = gcnew System::Drawing::Font( &Arial&,10 );
PrintDocument^ pd = gcnew PrintD
pd-&PrintPage += gcnew PrintPageEventHandler( this, &PrintingExample::pd_PrintPage );
pd-&Print();
streamToPrint-&Close();
catch ( Exception^ ex )
MessageBox::Show( ex-&Message );
// The PrintPage event is raised for each page to be printed.
void pd_PrintPage( Object^ /*sender*/, PrintPageEventArgs^ ev )
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = (float)ev-&MarginBounds.L
float topMargin = (float)ev-&MarginBounds.T
String^ line =
// Calculate the number of lines per page.
linesPerPage = ev-&MarginBounds.Height / printFont-&GetHeight( ev-&Graphics );
// Print each line of the file.
while ( count & linesPerPage && ((line = streamToPrint-&ReadLine()) != nullptr) )
yPos = topMargin + (count * printFont-&GetHeight( ev-&Graphics ));
ev-&Graphics-&DrawString( line, printFont, Brushes::Black, leftMargin, yPos, gcnew StringFormat );
// If more lines exist, print another page.
if ( line != nullptr )
ev-&HasMorePages = true;
ev-&HasMorePages = false;
// The Windows Forms Designer requires the following procedure.
void InitializeComponent()
this-&components = gcnew System::ComponentModel::C
this-&printButton = gcnew System::Windows::Forms::B
this-&ClientSize = System::Drawing::Size( 504, 381 );
this-&Text = &Print Example&;
printButton-&ImageAlign = System::Drawing::ContentAlignment::MiddleL
printButton-&Location = System::Drawing::Point( 32, 110 );
printButton-&FlatStyle = System::Windows::Forms::FlatStyle::F
printButton-&TabIndex = 0;
printButton-&Text = &Print the file.&;
printButton-&Size = System::Drawing::Size( 136, 40 );
printButton-&Click += gcnew System::EventHandler( this, &PrintingExample::printButton_Click );
this-&Controls-&Add( printButton );
// This is the main entry point for the application.
int main()
Application::Run( gcnew PrintingExample );
public class PrintingExample extends System.Windows.Forms.Form
private ponentModel.C
private System.Windows.Forms.Button printB
private Font printF
private StreamReader streamToP
public PrintingExample()
// The Windows Forms Designer requires the following call.
InitializeComponent();
} //PrintingExample
// The Click event is raised when the user clicks the Print button.
private void printButton_Click(Object sender, EventArgs e)
streamToPrint = new StreamReader(&C:\\My Documents\\MyFile.txt&);
printFont = new Font(&Arial&, 10);
PrintDocument pd = new PrintDocument();
pd.add_PrintPage(new PrintPageEventHandler(this.pd_PrintPage));
pd.Print();
streamToPrint.Close();
catch (System.Exception ex) {
MessageBox.Show(ex.get_Message());
} //printButton_Click
// The PrintPage event is raised for each page to be printed.
private void pd_PrintPage(Object sender, PrintPageEventArgs ev)
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.get_MarginBounds().get_Left();
float topMargin = ev.get_MarginBounds().get_Top();
String line = null;
// Calculate the number of lines per page.
linesPerPage = ev.get_MarginBounds().get_Height() /
printFont.GetHeight(ev.get_Graphics());
// Print each line of the file.
while ((count & linesPerPage &&
(line = streamToPrint.ReadLine()) != null)) {
yPos = topMargin + count * printFont.GetHeight(ev.get_Graphics());
ev.get_Graphics().DrawString(line, printFont, Brushes.get_Black(),
leftMargin, yPos, new StringFormat());
// If more lines exist, print another page.
if (line != null) {
ev.set_HasMorePages(true);
ev.set_HasMorePages(false);
} //pd_PrintPage
// The Windows Forms Designer requires the following procedure.
private void InitializeComponent()
this.components = new ponentModel.Container();
this.printButton = new System.Windows.Forms.Button();
this.set_ClientSize(new System.Drawing.Size(504, 381));
this.set_Text(&Print Example&);
printButton.set_ImageAlign(System.Drawing.ContentAlignment.MiddleLeft);
printButton.set_Location(new System.Drawing.Point(32, 110));
printButton.set_FlatStyle(System.Windows.Forms.FlatStyle.Flat);
printButton.set_TabIndex(0);
printButton.set_Text(&Print the file.&);
printButton.set_Size(new System.Drawing.Size(136, 40));
printButton.add_Click(new System.EventHandler(printButton_Click));
this.get_Controls().Add(printButton);
} //InitializeComponent
// This is the main entry point for the application.
public static void main(String[] args)
Application.Run(new PrintingExample());
} //PrintingExample
Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见。
受以下版本支持:2.0、1.1、1.0}

我要回帖

更多关于 beanlisthandler 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信