Other barcode Knowledge please visit: http://www.ybtiaoma.com, this article is for reference only, please do not reprint, thank you
UsingSystem;usingSystem.Drawing;usingSystem.Drawing.Printing;usingSystem.Runtime.InteropServices;usingSystem.Windows.Forms;/*2014-11-20 * Test printer new Beiyang btp-2100e Plus Citizen clp-s631 * Test results: Page size, spacing, left spacing can be used normally*/namespaceprintingexample{ Public Partial classFrnprinterlabel:form { PublicFrnprinterlabel () {InitializeComponent (); } PrivatePrintDocument M_printdoc =NULL;//Print a document PrivatePrintPreviewDialog M_printpreview =NULL;//Print Preview UI PrivatePrinterSettings psetting =NewPrinterSettings ();//instance print Settings Object Private floatM_pagewidth = 70F;//paper width mm units Private floatM_pageheight = 50F;//paper height mm unit Private voidForm1_Load (Objectsender, EventArgs e) {M_printdoc=NewPrintDocument ();//instance Print Document ObjectM_printpreview =NewPrintPreviewDialog (); //m_printPreview.PrintPreviewControl.AutoZoom = false;M_printPreview.PrintPreviewControl.Zoom =1; M_printpreview.width=Screen.PrimaryScreen.Bounds.Width; M_printpreview.height=Screen.PrimaryScreen.Bounds.Height; //Custom Paper SizeM_printDoc.DefaultPageSettings.PaperSize =NewPaperSize ("newpage70x40" , (int) (M_pagewidth/25.4* -) , (int) (M_pageheight/25.4* -)); //Custom Picture content Overall spacing/left spacingM_printdoc.originatmargins =true; M_printDoc.DefaultPageSettings.Margins.Top= (int)(2/25.4* -); M_printDoc.DefaultPageSettings.Margins.Left= (int)(2/25.4* -); //Print EventM_printdoc.printpage + =NewPrintpageeventhandler (m_printdoc_printpage); } Private voidButton1_Click (Objectsender, EventArgs e) {m_printdoc.print ();//Print } Private voidBtnview_click_1 (Objectsender, EventArgs e) {m_printpreview.document= M_printdoc;//display the printed document to the Preview dialog boxM_printpreview.showdialog (); } /// <summary> ///Draw what you want to print/// </summary> voidM_printdoc_printpage (Objectsender, PrintPageEventArgs e) {//Create text information e.graphics.drawstring ("Hangzhou Yun-Bo Barcode Technology Co., Ltd.",NewFont ("Song Body", the), Brushes.black,2,2); E.graphics.drawstring ("add: Jiubao, Jianggan District, Hangzhou, China \ r \ n"+"Tel: 0571-87298557\r\n"+"Contact information: 15158883623" , NewFont ("Song Body",Ten), Brushes.black,2, -); //CreateQR code--Reference DLL required
Dotnetbarcode Qrbarcode = new Dotnetbarcode ();//instance QR code
Qrbarcode.type = DotNetBarcode.Types.QRCode;
= DotNetBarcode.QRTextTypes.Automatic; Qrbarcode.qrwritebar (" Hangzhou Yun Bo Barcode Technology Co., Ltd. "22, E. Graphics); }}}
C # Control Barcode printer paper size, pitch, draw content (all barcode printers Common)