Use Dotnetbarcode to make basic common barcodes

Source: Internet
Author: User

 Core code:
/// <summary> ///Print one-dimensional code/// </summary> /// <param name= "Codetext" ></param> /// <param name= "G" ></param> /// <param name= "Pointx" ></param> /// <param name= "Pointy" ></param> /// <param name= "width" ></param> /// <param name= "height" ></param> Public voidPrintbarcode (stringCodetext, Graphics G,intPointx,intPointy,intWidthintheight) {C1barcode Code=NewC1barcode (); Code. CodeType=codetypeenum.code128; Code. Text=Codetext; Try{g.drawimage (code. Image, Pointx, pointy, width, height); } Catch(Exception ex) {if(Code. Image = =NULL) {MessageBox.Show ("A blank value exists in the field that needs to be printed, and the bar code is broken, check to see if some of the fields you want to print are maintained"+ ex. Message +"\ Some Information need to be printed are NULL, please contact maintain It"); } } } /// <summary> ///image compression generated two-dimensional code, * * * Tim/// </summary> /// <param name= "E" >e</param> /// <param name= "Qrbarcodeinfo" >Barcode Scan out of the information</param> /// <param name= "mapsize_x" >bitmap x Coordinate</param> /// <param name= "mapsize_y" >bitmap y-coordinate</param> /// <param name= "qrbarcode_x" >Barcode x Coordinate</param> /// <param name= "qrbarcode_y" >Barcode y-coordinate</param> /// <param name= "Qrbarcode_size" >Barcode Length Width</param> Public voidPrint_image_qrcode (System.Drawing.Printing.PrintPageEventArgs E,stringQrbarcodeinfo,intMapsize_x,intMapsize_y,intQrbarcode_x,intQrbarcode_y,intqrbarcode_size) {Dotnetbarcode QRCode=NewDotnetbarcode (DotNetBarcode.Types.QRCode); Qrcode.qrquitzone=0; //Qrcode.printchar = true;Bitmap Bitmap =NewBitmap (mapsize_x, mapsize_y);//4 * 4Graphics GP = Graphics.fromimage (bitmap);//take a picture as a graphicsQrcode.qrwritebar (Qrbarcodeinfo,0,0,2, GP);//draw two-dimensional code, the size of the picture is a two-dimensional code sizeGP. Dispose (); //picturebox1.image = bitmap;E.graphics.drawimage (Bitmap, qrbarcode_x, qrbarcode_y, Qrbarcode_size, qrbarcode_size);//Print the QR code image, zoom 35*4, 35*4 } /// <summary> ///print two-dimensional code/// </summary> /// <param name= "Codetext" ></param> /// <param name= "Pointx" ></param> /// <param name= "Pointy" ></param> /// <param name= "width" ></param> /// <param name= "height" ></param> /// <param name= "G" ></param> Public voidPrintbarcode_qrcode (stringCodetext,floatPointx,floatPointy,floatWidthfloatheight, Graphics g) {Dotnetbarcode QRCode=NewDotnetbarcode (DotNetBarcode.Types.QRCode); Qrcode.qrquitzone=0; Qrcode.writebar (Codetext, Pointx, pointy, width, height, g); }

Share progress, thank you for reading!

Use Dotnetbarcode to make basic common barcodes

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.