39 bar code Font: c39hrp24dltt installed on the computer
First look at the control interface
Convert the bar code font
private void button#click ( Object sender, eventargs E)
{< br> bitmap b1 = New Bitmap (convert. toint32 (textbox2.text), convert. toint32 (textbox3.text);
graphics G1 = graphics. fromimage (B1);
font font1 = New font (" c39hrp24dltt " , convert. toint32 (textbox4.text);
g1.drawstring (textbox1.text. tostring (), font1, brushes. black, New pointf (convert. toint32 (textbox5.text), convert. toint32 (textbox6.text);
picturebox1.backgroundimage = b1;
picturebox1.backgroundimagelayout = imagelayout. zoom;
}
Select printdocument1 as the document attributes of pagesetupdialog1, printdialog1, and printpreviewdialog1.
Add a printpage event printdocumentemediprintpage to printdocument1.
Print settings
Private VoidButton2_click (ObjectSender, eventargs E)
{
This. Pagesetupdialog1.showdialog ();
}
Print preview
Private VoidButton3_click (ObjectSender, eventargs E)
{
This. Printpreviewdialog1.showdialog ();
}
Print
Private VoidButton4_click (ObjectSender, eventargs E)
{
If(This. Printdialog1.showdialog () = dialogresult. OK)
{
This. Printdocument1.print ();
}
}
Print content settings
Private Void Printdocumentemediprintpage ( Object Sender, system. Drawing. Printing. printpageeventargs E)
{
// Print the entire form
// Image myformimage;
// Myformimage = new Bitmap (this. Width, this. Height );
// Graphics G = graphics. fromimage (myformimage );
// G. copyfromscreen (this. Location. X, this. Location. Y, 0, 0, this. size );
// E. Graphics. drawimage (myformimage, 0, 0 );
// Print this. groupbox1 with local content
Bitmap _ newbitmap = New Bitmap (groupbox1.width, groupbox1.height );
Groupbox1.drawtobitmap (_ newbitmap, New Rectangle ( 0 , 0 , _ Newbitmap. Width, _ newbitmap. Height ));
E. Graphics. drawimage (_ newbitmap, 0 , 0 , _ Newbitmap. Width, _ newbitmap. Height );
// Print content as custom text content
/* Font font = new font ("", 12 );
Brush Bru = brushes. blue;
For (INT I = 1; I <= 5; I ++)
{
E. Graphics. drawstring ("Hello World", Font, Bru, I * 20, I * 20 );
} */
}
Public form1 ()
PublicForm1 ()
{
Initializecomponent ();
This. Printdocument1.originatmargins =True;//Enable margin
This. Pagesetupdialog1.enablemetric =True;//In millimeters
}
No exception handling, for example, if the Print Service is not started,ProgramErrors may be reported unfriendly.
Converted to 39 bar code fonts. Supported characters include:
A-Z, 26 letters, case-insensitive, all represents big write;
0-9, 10 digits;
+-*/% $., 7 symbols;
Space, space.