在Web应用程序中使用条形码渲染框架生成条形码

安库尔

我正在使用Barcode Rendering Framework生成条形码。我已经下载了他们的dll。我可以看到,如何在Windows应用程序中完成它。我想做同样的事情,即生成条形码并在Web应用程序中使用它。以下是可以使用的问题的链接。用于.NET的免费Barcode API,以下是代码:

Code39BarcodeDraw barcode39 = BarcodeDrawFactory.Code39WithoutChecksum;
System.Drawing.Image img = barcode39.Draw("Hello World", 40);
pictureBox1.Image = barcode39.Draw("Hello World", 40);

如何在Web应用程序中使用相同的功能?

罗伊·迪克特

您可以在ASP.NET中使用相同的代码,但需要通过HTTP输出图像。

假设您有一个包含以下内容的ASP.NET网页:

<IMG SRC="BarCode.aspx?par1=HelloWorld40OrWhatever" />

然后,您的BarCode.aspx页面必须生成并输出图像:

Code39BarcodeDraw barcode39 = BarcodeDrawFactory.Code39WithoutChecksum;
System.Drawing.Image img = barcode39.Draw("Hello World", 40);

Response.Clear();
Response.Type = "image/png";
img.Save(Response.OutputStream, Imaging.ImageFormat.Png);
Response.Flush();
Response.End();

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章