在itexsharp中创建QR码

时间:2018-03-27 22:08:53

标签: c# zend-framework

我使用ITexSharp用C#创建PDF文件。 现在我需要在Itextshpar里面创建一个QR码。我使用Zen Barcorde dll创建QRCode,我在Picture Box中创建代码。但我无法将Picture Box对象转换为Image以与ITexSharp Image对象一起使用。

这是我的代码:

Zen.Barcode.CodeQrBarcodeDraw qrCode = Zen.Barcode.BarcodeDrawFactory.CodeQr;
PictureBox picQRImage = new PictureBox();
picQRImage.Image = qrCode.Draw("12245654", 50);
Image img = qrCode.Draw(pStrNuFactura, 50); //Can not convert explicit
Image img = (Image) qrCode.Draw(pStrNuFactura, 50); //Not working

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

感谢您的帮助。 我的解决方案是:

System.Drawing.Image imgZenBarcode; 
iTextSharp.text.Image imgQRCode; 
Zen.Barcode.CodeQrBarcodeDraw qrCode = Zen.Barcode.BarcodeDrawFactory.CodeQr;           
imgZenBarcode = qrCode.Draw( "123456", 50);
imgQRCode = iTextSharp.text.Image.GetInstance(imgZenBarcode, System.Drawing.Imaging.ImageFormat.Png);