Printing the image returned by the Barcode() call may be accomplished by any of the printing techniques available for Visual Studio.NET project. However, probably the most useful approach is to use the DrawImage() method in a PrintPage handler as illustrated below, and in the examples provided with the components:
Visual Basic
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.PageUnit = GraphicsUnit.Document '
e.Graphics.DrawImage(Abcnet1.Barcode(e.Graphics), 300.0F, 300.0F)
e.HasMorePages = False
End Sub
C#
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.PageUnit = GraphicsUnit.Document;
e.Graphics.DrawImage(abcnet1.Barcode(e.Graphics), 500F,500F);
e.HasMorePages = false;
}
J#
private void pd_PrintPage(Object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.get_Graphics().set_PageUnit(GraphicsUnit.Document);
e.get_Graphics().DrawImage(abcnet1.Barcode(e.get_Graphics()),500F, 500F);
e.set_HasMorePages(false);
}
While the PageUnit setting can be any of the allowed values, we have found that the most accurately sized barcodes are produced when the highest resolution setting (Document, equivalent to 300 units per inch) is used.
More: