How to Export Barcodes as Streams
How to export barcodes as stream in C#
- Create Barcodes
- Convert Barcodes to Stream
Install with NuGet
Manually install into your project
Barcodes produced from IronBarcode does not necessarily need to be saved into disk. Being a good API it is, barcodes produced from IronBarcode can take up many types, including
MemoryStream to be used further in a program or application.
Barcodes can first be written in IronBarcode by calling
CreateBarcode() method from
BarcodeWriter class. To write QR codes on the other hand, call
CreateQrCode() method from
QRCodeWriter class to produce a QR code. More info on how to write/create a barcode, please refer to this article. The code snippet below demonstrates on how to create a simple one-dimensional barcode and a QR code.
'INSTANT VB TODO TASK: The following line uses invalid syntax: ':path=/static-assets/barcode/content-code-examples/how-@to/CreateBarcode.cs
Convert Barcode to Stream
There are multiple methods that a user can use to convert the
MemoryStream. These methods are for simplicity, in which users can use based on the desired image format stream. Below are the list of methods involved:
- ToGifStream() : This method converts the
System.IO.MemoryStreamtype for GIF image.
- ToJpegStream() : This method converts the
System.IO.MemoryStreamtype for JPEG/JPG image.
- ToPdfStream() : This method returns
System.IO.MemoryStreamthat contains 1 page of PDF document containing the
- ToPngStream() : This method converts the
System.IO.MemoryStreamtype for PNG image.
- ToStream() : This method converts the
System.IO.MemoryStreamtype object of PNG image format as default. Users can however, can input
AnyBitmap.ImageFormatenum field as argument in this method to specify the desired image stream format.
- ToTiffStream() : This method returns
System.IO.MemoryStreamtype object from the
GeneratedBarcodewith TIFF image format.
Now let us apply one of the methods to convert
System.IO.MemoryStream object using the code snippet below:
'INSTANT VB TODO TASK: The following line uses invalid syntax: ':path=/static-assets/barcode/content-code-examples/how-@to/ConvertToMemoryStream.cs
From the code snippet above, users are able to convert a barcode by either attaching the stream conversion method on the
GeneratedBarcode object or attach the method inline with
In a nutshell, it is very easy and convenient to use IronBarcode to create and export barcodes to
MemoryStream type object by offering a straightforward method. Try it!