Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在asp.net中打印条形码?_C#_Asp.net_Printing_Barcode Printing - Fatal编程技术网

C# 如何在asp.net中打印条形码?

C# 如何在asp.net中打印条形码?,c#,asp.net,printing,barcode-printing,C#,Asp.net,Printing,Barcode Printing,我有一个asp.net网站,我想用c打印一些条形码。我使用IDAutomationHC39M字体,如下所示: public static void PrintSmallBarcode(HtmlGenericControl divBarCode, string barCode) { System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image(); using

我有一个asp.net网站,我想用c打印一些条形码。我使用IDAutomationHC39M字体,如下所示:

public static void PrintSmallBarcode(HtmlGenericControl divBarCode, string barCode)
    {
        System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
        using (Bitmap bitMap = new Bitmap(75, 18))
        {
            using (Graphics graphics = Graphics.FromImage(bitMap))
            {
                Font oFont = new Font("IDAutomationHC39M", 7);
                PointF point = new PointF(0, 0);
                SolidBrush blackBrush = new SolidBrush(Color.Black);
                SolidBrush whiteBrush = new SolidBrush(Color.White);
                graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);
                graphics.DrawString(barCode, oFont, blackBrush, point);
            }
            using (MemoryStream ms = new MemoryStream())
            {
                bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] byteImage = ms.ToArray();

                Convert.ToBase64String(byteImage);
                imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
                imgBarCode.CssClass = "cssbarcode";
            }
        }
        div.Controls.Add(imgBarCode);
}
它可以工作,但条形码的质量很低,我的条形码阅读器设备无法读取它。我不能增加图像的大小,当然我看到很多好的条形码比我的尺寸小。我用free3of9.ttf替换IDAutomationHC39M字体,但这种字体只画数字,没有条形码线!。
我怎样才能得到更好的条形码

这是条形码字体长期存在的问题;它们体积巨大,扫描效果很差,因为打印机试图消除这些条的别名


使用图像而不是字体来绘制条形码。例如,有许多可用的软件包。

您可以使用其他数据更改条形码的大小。我使用keepautomation在Visual C ASP.NET项目中创建条形码图像。设置后,我可以预览条形码的大小。

此链接可以回答问题,最好在这里包括答案的基本部分,并提供链接供参考。如果链接页面发生更改,则仅链接的答案可能无效。