Hi,
I am using BarCodeBuilder to generate 2D DataMatrix barocde and save it to stream. The barcode image stream then gets embedded into a PDF. The problem is that that when the barcode is saved to the stream, the stream is either corrupted or just invalid and can’t be read by anything. Below is the code:
Dim codeBuilder As New BarCodeBuilder(barCodeData,Aspose.BarCode.Symbology.DataMatrix)
codeBuilder.Resolution = New Resolution(125, 125, ResolutionMode.Graphics)
codeBuilder.CodeLocation = CodeLocation.None
Dim mStream as Stream
codeBuilder.Save(mStream, System.Drawing.Imaging.ImageFormat.Png)
Everything looks pretty simple but try reading the mStream variable using below method. The while loop never executes. If I save the same barcode to an image file, it works fine. If I then read this file as a stream, everything works fine also, but the stream saved by the BarCodeBuilder just doesn’t work. Please advise. Thanks.
public static void CopyStream(Stream input, Stream output)
{
byte[] buffer = new byte[8 * 1024];
int len;
while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, len);
}
}