IronBarcode How-Tos .NET Create Barcodes as Streams How to Export Barcodes as Streams Hairil Hasyimi Bin Omar Updated:June 22, 2025 IronBarcode offers the capability to create barcodes and directly convert them to streams, including the use of MemoryStream for further application within your program. This efficient feature eliminates disk I/O overhead, improves performance, reduces storage usage, enhances data security, and provides a more flexible workflow for seamless integration with various applications. How to Export Barcodes as Stream in C# Download the C# library to export barcodes as stream Create various barcode types from input values Convert the generated barcode to a stream Use specific methods to export different image formats as stream Apply further processing to the stream data Get started with IronBarcode Start using IronBarcode in your project today with a free trial. First Step: Start for Free Export Barcode as Stream Example Once you have created the barcode with the desired value, you can utilize the ToStream method to convert the generated barcode into a MemoryStream, with the default format being PNG image. This functionality also works with the QRCodeWriter, even after applying custom styling. :path=/static-assets/barcode/content-code-examples/how-to/create-barcode-as-stream-to-stream.cs using IronBarCode; using System.IO; // Create one-dimensional barcode GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("IronBarcode1234", BarcodeEncoding.Code128); // Convert barcode to stream Stream barcodeStream = barcode.ToStream(); // Create QR code GeneratedBarcode qrCode = QRCodeWriter.CreateQrCode("IronBarcode1234"); // Convert QR code to stream Stream qrCodeStream = qrCode.ToStream(); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Export Barcode as Stream in Various Image Formats There are multiple methods that a user can use to convert the barcode object into a MemoryStream. These methods simplify the process, allowing users to choose based on the desired image format stream. Below is the list of available methods: BinaryStream property: Returns a System.IO.Stream of the barcode rendered as a Bitmap image. ToGifStream(): For GIF image format. ToJpegStream(): For JPEG/JPG image format. ToPdfStream(): For PDF document format. ToPngStream(): For PNG image format. ToStream(): For PNG image format by default. Users can, however, input the AnyBitmap.ImageFormat enum field as an argument in this method to specify the desired image stream format. ToTiffStream(): For TIFF image format. Now, let us use the ToJpegStream and ToStream methods to output streams in JPEG image format using the code snippet below: :path=/static-assets/barcode/content-code-examples/how-to/create-barcode-as-stream-to-jpeg-stream.cs using IronBarCode; using IronSoftware.Drawing; using System.IO; // Create one-dimensional barcode GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("IronBarcode1234", BarcodeEncoding.Code128); // Convert barcode to JPEG stream Stream barcodeStream = barcode.ToStream(AnyBitmap.ImageFormat.Jpeg); // Create QR code GeneratedBarcode qrCode = QRCodeWriter.CreateQrCode("IronBarcode1234"); // Convert QR code to JPEG stream Stream qrCodeStream = qrCode.ToJpegStream(); Imports IronBarCode Imports IronSoftware.Drawing Imports System.IO ' Create one-dimensional barcode Private barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("IronBarcode1234", BarcodeEncoding.Code128) ' Convert barcode to JPEG stream Private barcodeStream As Stream = barcode.ToStream(AnyBitmap.ImageFormat.Jpeg) ' Create QR code Private qrCode As GeneratedBarcode = QRCodeWriter.CreateQrCode("IronBarcode1234") ' Convert QR code to JPEG stream Private qrCodeStream As Stream = qrCode.ToJpegStream() $vbLabelText $csharpLabel In summary, IronBarcode makes it incredibly easy and convenient to create and export barcodes to a MemoryStream object, providing a straightforward method for achieving this. Frequently Asked Questions What are the advantages of exporting barcodes as streams using C#? Exporting barcodes as streams using IronBarcode in C# offers several advantages, including eliminating disk I/O overhead, improving performance, reducing storage usage, enhancing data security, and enabling seamless integration into various applications. How do I export a barcode to a stream in C#? To export a barcode to a stream in C#, use IronBarcode's ToStream method after generating the barcode. This converts the barcode into a MemoryStream, with the default format being PNG. What image formats are supported for exporting barcodes as streams? IronBarcode supports exporting barcodes to several image formats as streams, including GIF, JPEG, PDF, PNG, and TIFF. Methods like ToGifStream(), ToJpegStream(), and ToPdfStream() are available for these formats. Is it possible to convert a barcode to a JPEG stream in C#? Yes, you can convert a barcode to a JPEG stream using IronBarcode's ToJpegStream method, which outputs the barcode as a MemoryStream in JPEG format. Can I customize a QR code before exporting it as a stream? Yes, you can customize a QR code using IronBarcode before exporting it as a stream. This includes applying custom styling to the QR code. What is the default format when exporting a barcode to a stream? The default format when exporting a barcode to a stream using IronBarcode's ToStream method is PNG. How can I specify a different image format when using the ToStream method? You can specify a different image format by passing the AnyBitmap.ImageFormat enum field as an argument to the ToStream() method in IronBarcode. What are some practical applications of converting barcodes to streams? Practical applications include using the MemoryStream from a barcode to save it to a file or to further process the barcode data within an application. How do I begin using a .NET library to export barcodes as streams? To begin using IronBarcode, download the C# library, create barcodes from input values, and use the provided methods to export them as streams in your desired format. 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