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