IronBarcode How-Tos .NET Create Barcodes as PDF How to Export Barcodes as PDF Hairil Hasyimi Bin Omar Updated:June 22, 2025 In this article, we'll explore how we can use IronBarcode to export barcodes to PDF. With IronBarcode, barcodes can be exported as either a file, binary data, or memory stream. How to Export Barcodes as PDF in C# Download C# library to Export Barcodes as PDFs in C# Export Barcodes as PDF File Export Barcodes as PDF Binary Data Export Barcodes as PDF Stream Start using IronBarcode in your project today with a free trial. First Step: Start for Free Export Barcodes as PDF File To save a barcode as a PDF file, first create a GeneratedBarcode object with BarcodeWriter.CreateBarcode and then use the SaveAsPdf() method to convert and save a file to disk. The following code snippet demonstrates how this works. :path=/static-assets/barcode/content-code-examples/how-to/ExportBarcodeAsPdfFile.cs using IronBarCode; GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.DataMatrix); myBarcode.SaveAsPdf("myBarcode.pdf"); Imports IronBarCode Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.DataMatrix) myBarcode.SaveAsPdf("myBarcode.pdf") $vbLabelText $csharpLabel Export Barcodes as PDF Binary Data To export as PDF binary data, generate a barcode and then call the ToPdfBinaryData() method. This outputs the PDF binary data as a byte[] array. The following code snippet demonstrates how this works. :path=/static-assets/barcode/content-code-examples/how-to/ExportBarcodeAsPdfBinaryData.cs using IronBarCode; GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.DataMatrix); byte[] myBarcodeByte = myBarcode.ToPdfBinaryData(); Imports IronBarCode Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.DataMatrix) Private myBarcodeByte() As Byte = myBarcode.ToPdfBinaryData() $vbLabelText $csharpLabel Export Barcodes as PDF Stream To export as a memory stream, generate a barcode and then call the ToPdfStream() method. This method returns a System.IO.Stream object. The following code snippet demonstrates how this works. :path=/static-assets/barcode/content-code-examples/how-to/ExportBarcodeAsPdfStream.cs using IronBarCode; using System.IO; GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.DataMatrix); Stream myBarcodeStream = myBarcode.ToPdfStream(); Imports IronBarCode Imports System.IO Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.DataMatrix) Private myBarcodeStream As Stream = myBarcode.ToPdfStream() $vbLabelText $csharpLabel Frequently Asked Questions What is this powerful .NET Barcode Library? IronBarcode is a powerful .NET Barcode Library that allows you to create, read, and export barcodes in various formats, including PDF. How can I export barcodes as a PDF file? To export barcodes as a PDF file using IronBarcode, create a GeneratedBarcode object with BarcodeWriter.CreateBarcode and use the SaveAsPdf() method to save it to disk. How do I export barcodes as PDF binary data? To export barcodes as PDF binary data using IronBarcode, generate a barcode and then use the ToPdfBinaryData() method, which outputs the PDF binary data as a byte[] array. Can I export barcodes as a PDF stream? Yes, you can export barcodes as a PDF stream by generating a barcode and calling the ToPdfStream() method in IronBarcode, which returns a System.IO.Stream object. What are the steps to download the library needed to export barcodes as PDFs in C#? To download the library, visit the NuGet package page for the BarCode library and follow the instructions to install it in your C# project. What code is needed to save a barcode as a PDF file? Use the following code snippet with IronBarcode: ```csharp using IronBarCode; GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("Example", BarcodeEncoding.Code128); barcode.SaveAsPdf("ExampleBarcode.pdf"); Console.WriteLine("Barcode saved as PDF file."); ``` How do I convert a barcode to PDF binary data? To convert a barcode to PDF binary data using IronBarcode, use the following code snippet: ```csharp using IronBarCode; GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("Example", BarcodeEncoding.Code128); byte[] pdfBinaryData = barcode.ToPdfBinaryData(); Console.WriteLine("Barcode PDF binary data generated."); ``` What method should be used to convert a barcode to a PDF stream? Use the ToPdfStream() method in IronBarcode to convert a barcode to a PDF stream, which returns a System.IO.Stream object. Is it possible to work with the PDF stream to save it as a file or send it over a network? Yes, once you have the PDF stream from the ToPdfStream() method in IronBarcode, you can work with it as you would with any System.IO.Stream object, including saving it to a file or sending it over a network. Hairil Hasyimi Bin Omar Chat with engineering team now Software Engineer Like all great engineers, Hairil is an avid learner. He’s refining his knowledge of C#, Python, and Java, using that knowledge to add value to team members across Iron Software. Hairil joined the Iron Software team from Universiti Teknologi MARA in Malaysia, where he graduated with a Bachelor's degree in Chemical and Process Engineering. Ready to Get Started? Free NuGet Download Total downloads: 1,743,856 View Licenses