As you probably already know, most printing jobs within .NET Framework are performed by using the PrintDocument class under System.Drawing.Printing namespace. The PrintDocument class is used to set the properties that describe what and where to print content such us strings, images and so on.
The main method the PrintDocument class features is Print which starts the document's printing process. After Print method is invoked, the PrintDocument raises a PrintPage event for each page to be printed. Here is where you should add your printing logic to an event handler for that event.
If your application needs to feature barcoding capabilities, it's also probably that printing documents containing barcode images are required as well.
Barcode Professional control features an overloaded method called DrawOnCanvas which lets you to draw the barcode image on any GDI+ Graphics object - an instance of System.Drawing.Graphics class. The PrintDocument's PrintPage event exposes a Graphics object where to paint the page content and here is where that Graphics object must be passed to the DrawOnCanvas method in order to get the barcode image printed.
Neodynamic Barcode Professional SDK 2.0 for .NET
Microsoft .NET Framework 2.0 (or greater)
Microsoft Visual Studio 2005/2008 or Visual Studio 2005/2008 Express Editions (Visual Basic 2005/2008 Express, Visual C# 2005/2008 Express, etc)
Private Sub printDocumentObject_PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs)
'Create a Barcode Professional object
Dim bcp As New BarcodeProfessional()
'Barcode settings
bcp.Symbology = Symbology.Code39
bcp.Code = "123456789"
'...
'Print the barcode at x=1in, y=1in using DrawOnCanvas method
bcp.DrawOnCanvas(e.Graphics, New PointF(1F, 1F))
End Sub
private void printDocumentObject_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//Create a Barcode Professional object
BarcodeProfessional bcp = new BarcodeProfessional();
//Barcode settings
bcp.Symbology = Symbology.Code39;
bcp.Code = "123456789";
//...
//Print the barcode at x=1in, y=1in using DrawOnCanvas method
bcp.DrawOnCanvas(e.Graphics, new PointF(1f, 1f));
}
Private Sub printDocumentObject_PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs)
'Create a Barcode Professional object
Dim bcp As New BarcodeProfessional()
'Barcode settings
bcp.Symbology = Symbology.Code39
bcp.Code = "123456789"
'...
'Print the barcode at x=2in, y=3in and scaled at 50% using DrawOnCanvas method
bcp.DrawOnCanvas(e.Graphics, New PointF(2F, 3F), 0.5F)
End Sub
private void printDocumentObject_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//Create a Barcode Professional object
BarcodeProfessional bcp = new BarcodeProfessional();
//Barcode settings
bcp.Symbology = Symbology.Code39;
bcp.Code = "123456789";
//...
//Print the barcode at x=2in, y=3in and scaled at 50% using DrawOnCanvas method
bcp.DrawOnCanvas(e.Graphics, new PointF(2f, 3f), 0.5f);
}
Private Sub printDocumentObject_PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs)
'Create a Barcode Professional object
Dim bcp As New BarcodeProfessional()
'Barcode settings
bcp.Symbology = Symbology.Code39
bcp.Code = "123456789"
'...
'Print the barcode to fit an area of size 2x1in using DrawOnCanvas method
bcp.DrawOnCanvas(e.Graphics, New PointF(0,0), New SizeF(2F,1F))
End Sub
private void printDocumentObject_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//Create a Barcode Professional object
BarcodeProfessional bcp = new BarcodeProfessional();
//Barcode settings
bcp.Symbology = Symbology.Code39;
bcp.Code = "123456789";
//...
//Print the barcode to fit an area of size 2x1in using DrawOnCanvas method
bcp.DrawOnCanvas(e.Graphics, New PointF(0,0), New SizeF(2f,1f));
}
Tweet |
|
We provide best-in-class customer service and support directly from members of our dev team! If we are available when you contact us, you will get a response in few minutes; otherwise the maximum turnaround is 24hs in most cases.