I need a barcode print module in my application, but cannot figure out how to print barcodes correctly. It seems that the resolution is too low. I am using Zen Barcode . As you can see in the attached photo, the top bar code is printed from the printer software, confirming that the printer is in order, printed from my code from bottom to bottom:
[WPF]
<Grid x:Name="_printSerialBcode" Margin="9" Visibility="Visible"> <Image x:Name="serial_bcode1" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="2"/> </Grid>
[WITH#]
private void printJob() { // use printer we need SetDefaultPrinter("Brother QL-700"); //draw barcodes BarcodeDraw bc = BarcodeDrawFactory.Code128WithChecksum; Bitmap serial_bitmap = (Bitmap)bc.Draw(serial, 20); ImageConverter ic = new ImageConverter(); //generate bitmap serial_bcode1.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(serial_bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); var dlg = new PrintDialog(); //print main label dlg.PrintTicket.CopyCount = 1; // number of copies dlg.PrintTicket.PageOrientation = PageOrientation.Landscape; dlg.PrintVisual(_printSerialBcode, "Barcode"); //change default printer to original one SetDefaultPrinter(defaultPrinter); }

source share