从winforms应用程序打印条形码

Ser*_*sen 3 c# printing barcode winforms

我想在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????);
    }
}
Run Code Online (Sandbox Code Playgroud)

Fir*_*ock 6

我们使用条形码渲染框架:

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