我的应用程序中需要条形码打印模块,但无法弄清楚如何正确打印条形码。看起来它的分辨率太低了。 我正在使用Zen Barcode。正如您在附带的照片中看到的那样,顶部条形码是从打印机软件打印出来的,证明打印机没问题,底部图片是从我的代码中打印出来的:
[WPF]
<Grid x:Name="_printSerialBcode" Margin="9" Visibility="Visible">
<Image x:Name="serial_bcode1" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="2"/>
</Grid>
[C#]
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);
}