How to Integrate Aspose.BarCode with Aspose.PDF

Create a PDF Document using Aspose.PDF

After the barcode image is saved to a MemoryStream, we are done with the barcode image. The only thing now needed is to add this barcode image (saved in the MemoryStream) to the PDF document. So, now it’s time to create a PDF document using Aspose.PDF so that we can add this newly generated barcode image to it. Let’s start by creating an instance of Aspose.Pdf.Document class and then add a page to this document instance as shown below:

Add Barcode Image to the PDF Document

Aspose.Pdf provides a Document class that represents a PDF document. We can create an instance of the Document class by calling its empty constructor. After creating an empty document, we will add a page by calling Document.Pages.Add method. The Barcode image shall be generated in the Memorystream using BarcodeGenerator.Save method with Memorystream as a parameter and BMP as BarCodeImageFormat. The PdfFileMend class object shall be initiated provided by Aspose.PDF to add Barcode image to PDF as shown below.


Aspose.BarCode can easily be integrated with any of the Aspose Components to create rich applications for fulfilling the maximum requirements of the users. The most interesting thing is that any change in Aspose.BarCode version would not affect its integration with other Aspose Components because Aspose.PDF only deals with the barcode image produced by the Aspose.BarCode and not its internal structure.