Print Devexpress barcodecontrol QR code using WinForm
/// <summary> ///Handles The ItemClick event of the barButtonItem2 control. /// </summary> /// <param name= "Sender" >The source of the event.</param> /// <param name= "E" > the<see cref= "DevExpress.XtraBars.ItemClickEventArgs"/>instance containing the event data.</param> Private voidBarbuttonitem2_itemclick (Objectsender, DevExpress.XtraBars.ItemClickEventArgs e) {printdialog1.document=PrintDocument1; Printpreviewcontrol1.document=PrintDocument1; Printdocument1.printpage+=Printdocument1_printpage; if(Printdialog1.showdialog () = =DialogResult.OK) {printdocument1.print (); } } /// <summary> ///Prints to graphics. /// </summary> /// <param name= "Graphics" >The graphics.</param> /// <param name= "Bounds" >The bounds.</param> Public voidPrinttographics (graphics graphics, Rectangle bounds) {Bitmap Bitmap=NewBitmap (Barcodecontrol1.width, barcodecontrol1.height); Barcodecontrol1.drawtobitmap (Bitmap,NewRectangle (0,0, Bitmap. Width, Bitmap. Height)); Rectangle Target=NewRectangle (0,0, bounds. Width, bounds. Height); DoubleXScale = (Double) bitmap. Width/bounds. Width; DoubleYscale = (Double) bitmap. Height/bounds. Height; if(XScale <Yscale) target. Width= (int) (XScale * target. Width/Yscale); ElseTarget. Height= (int) (Yscale * target. Height/XScale); Graphics. PageUnit=Graphicsunit.display; Graphics. DrawImage (bitmap, target); } /// <summary> ///Handles The PrintPage event of the PrintDocument1 control. /// </summary> /// <param name= "Sender" >The source of the event.</param> /// <param name= "E" > the<see cref= "System.Drawing.Printing.PrintPageEventArgs"/>instance containing the event data.</param> Private voidPrintdocument1_printpage (Objectsender, System.Drawing.Printing.PrintPageEventArgs e) {Printtographics (e.graphics, e.marginbounds); }
WinForm Call PrintDocument