我想在具有正常打印功能的winforms应用程序中打印条形码,而不是通过类似ZPL的语言进行打印。我可以打印任何东西,而不仅仅是普通条形码

using (PrintDocument pd = new PrintDocument())
{
    pd.PrintController = new StandardPrintController();
    pd.PrinterSettings.PrinterName = "Printer";
    pd.PrintPage += new PrintPageEventHandler(pd_PrintLabel);
    pd.Print();
}

private void pdPrintLabel(object sender, PrintPageEventArgs ev)
{
    Graphics g = ev.Graphics;

    using (Font f = new Font(FontFamily.GenericSansSerif, 6))
    {
       g.DrawString(????????? what to do for barcode????);
    }
}

最佳答案

我们正在使用Barcode Rendering Framework

BarcodeDraw bdraw = BarcodeDrawFactory.GetSymbology(BarcodeSymbology.Code128);
Image barcodeImage = bdraw.Draw("barcodetext", barcodeImageHeight);
g.DrawImage(barcodeImage, barcodeRect);

09-27 03:25
查看更多