We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

2D Barcode Evaluation

Hi, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We are doing some evaluation for barcode generation and recognition and we are using 2D barcode, but the temporary license only support 1D. Would you like to get us another temporary license so that we can do 2D barcode evaluation? BTW, Is aspose able provide the information of the location of the barcode within the image?

Regards

Walter Huang


This message was posted using Email2Forum by sheliah.
Hi Walter,

Thanks for considering Aspose.

The temporary license supports 2D barcodes and it should generate as well as recognize all the supported 2D barcodes.

The barcode builder creates an image file and there is no direct way for specifying the position of barcode within the image. But, you can control the location by specifying margins (left, right, top and bottom). The sample code below generates and recognizes Pdf417 barcode:

// set license for barcode generation
Aspose.BarCode.License licGen = new Aspose.BarCode.License();
licGen.SetLicense(@"e:\data\aspose\lic\Aspose.Total.lic");
// set license for barcode recognition
Aspose.BarCodeRecognition.License licRec = new Aspose.BarCodeRecognition.License();
licRec.SetLicense(@"e:\data\aspose\lic\Aspose.Total.lic");

string strCodeText = "test-123";

// generate barcode to stream
BarCodeBuilder builder = new BarCodeBuilder();
builder.CodeText = strCodeText;
builder.SymbologyType = Symbology.Pdf417;
builder.CodeLocation = CodeLocation.None;
builder.AutoSize = true;
builder.GraphicsUnit = GraphicsUnit.Pixel;
// 50 pixels from left and 10 pixels from top
builder.Margins = new MarginsF(50, 1, 10, 1);

MemoryStream stream = new MemoryStream();
builder.Save(stream, ImageFormat.Png);

// read from stream
stream.Position = 0;
BarCodeReader reader = new BarCodeReader(stream, BarCodeReadType.Pdf417);
while (reader.Read())
{
if (strCodeText == reader.GetCodeText())
MessageBox.Show("Valid Codetext found: " + reader.GetCodeText());
else
MessageBox.Show("Invalid Codetext found: " + reader.GetCodeText());
}
reader.Close();