C # Control Barcode printer paper size, pitch, draw content (all barcode printers Common)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.