Create pdf documents with 2D barcodes from .NET
How can I create pdf documents with 2D barcodes (for example QR code http://en.wikipedia.org/wiki/QR_Code) from .NET application?
I will (probably) use iTextSharp for creating the docum开发者_JAVA百科ents. Which component should I use for drawing 2D barcodes?
Could you not create an Image with the bar code and embed it into the PDF?
iTextSharp supports several barcode standards (as per the tutorial at http://itextsharp.sourceforge.net/tutorial/ch09.html)
* Barcode39: code 39 and code 39 extended
* Barcode128: code 128 and the special encoding UCC/EAN-128
* BarcodeEAN: EAN13, EAN8, UPCA, UPCE, and EAN with supplemental 5, EAN with supplemental 5, EAN with supplemental 2
* BarcodeInter25: interleaved 2 of 5
* BarcodePostnet: postnet and planet
You can use the Aspose barcode and Aspose pdf components to create a series of documents with barcodes easily.
There's plenty of examples in the forum demonstrating examples of how to do this. In addition, you will also be able to extract the barcode values from the original PDF using these components if that becomes a future requirement.
PDFFlow library supports barcodes including QR codes (variants 1-40, four levels of error correction available).
In your C# project, add reference to a free library Gehtsoft.PDFFlowLib.Barcodes from nuget.org.
Exampe of adding QR code to a paragraph:
DocumentBuilder.New()
.AddSection()
.AddParagraph()
.AddQRCode("Some information for sharing",
QRCodeEncodingMethod.Binary,
QRCodeErrorCorrection.M,
QRCodeVersion.Version4,
4) .ToDocument()
.Build("Result.pdf");
Exampe of adding a QR code with a URL to a table cell:
var textUrl = "https://www.nuget.org/packages/Gehtsoft.PDFFlowLib/";
DocumentBuilder.New()
.AddSection()
.AddTable()
.SetWidth(230)
.AddColumnToTable()
.AddColumnToTable()
.AddRow()
.AddCellToRow("QR-code in table cell")
.AddCell()
.AddQRCodeUrl(textUrl)
.SetWidth(150)
.ToDocument()
.Build("Result.pdf");
Here is a tutorial with many examples: AddingQRCodes.
Note, that Gehtsoft.PDFFlowLib.Barcodes library is an extension of PDFFlow library for generation PDF documents.
You can do it by using DevExpress Reports, they are supporting 2D Barcode in there reports, also they are supporting exporting the reports to a lot of formats like PDF.
Google says http://sourceforge.net/projects/pdf417lib/ though it hasn't been updated since 2005 and is in beta. Please do report back if you use this.
(Feels like 2D barcodes is quite unusual, probably because just having a ID is often sufficient and 1D-scanners are waaaay cheaper.)
精彩评论