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 How can I export barcodes as a PDF file in C#? To export barcodes as a PDF file in C#, use IronBarcode by creating a GeneratedBarcode object with BarcodeWriter.CreateBarcode and then apply the SaveAsPdf() method to save the file to disk. What steps are involved in exporting barcodes as PDF binary data? In C#, you can export barcodes as PDF binary data using IronBarcode by generating a barcode and calling the ToPdfBinaryData() method, which outputs the data as a byte[] array. How do I export a barcode as a PDF stream in .NET? To export a barcode as a PDF stream in .NET, use IronBarcode's ToPdfStream() method, which returns a System.IO.Stream object that can be manipulated as needed. What is the process to download the library for exporting barcodes as PDFs in C#? To download the necessary library for exporting barcodes as PDFs in C#, visit the NuGet package page for the Barcode library and follow the installation instructions for integration into your project. Can I convert barcodes to PDF without saving them to disk? Yes, by using IronBarcode, you can convert barcodes to PDF without saving them to disk by utilizing the ToPdfBinaryData() method for binary data or ToPdfStream() for a stream. What code is needed to create and save a barcode as a PDF in C#? To create and save a barcode as a PDF in C#, use this code snippet with IronBarcode: using IronBarCode; GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("Example", BarcodeEncoding.Code128); barcode.SaveAsPdf("ExampleBarcode.pdf"); Console.WriteLine("Barcode saved as PDF file."); How can PDF binary data be generated from a barcode? Use IronBarcode to generate PDF binary data from a barcode with the following snippet: using IronBarCode; GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("Example", BarcodeEncoding.Code128); byte[] pdfBinaryData = barcode.ToPdfBinaryData(); Console.WriteLine("Barcode PDF binary data generated."); Is it feasible to send a barcode PDF stream over a network? Yes, with IronBarcode, once you have the PDF stream obtained from the ToPdfStream() method, you can send it over a network like any System.IO.Stream object. 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 ...Read More Ready to Get Started? Free NuGet Download Total downloads: 1,818,593 View Licenses