Free Support Forum - aspose.com

How to migrate from older version of BarcodeGenerator

Hello

in the past we used BarCodeGenerator in Aspose.Barcode 19.5. Now we would like to upgrade to newer version. Unfortunateley there has been an API change (BARCODENET-37206) and BarCodeGenerator has changed.
I am not sure how to migrate the following code, especially setting the margins, location and encodeMode of DataMatrix . Can you help me?
Thanks a lot.

	try
	{
		generator = new BarCodeGenerator(barcodeType, barcodeValue);
		generator.getMargins().getTop().setPixels(0);
		generator.getMargins().getBottom().setPixels(0);
		generator.getMargins().getLeft().setPixels(0);
		generator.getMargins().getRight().setPixels(0);
		generator.getCodeTextStyle().setLocation(CodeLocation.NONE);

		if (EncodeTypes.DATA_MATRIX.equals(barcodeType))
		{
			generator.getDataMatrix().setEncodeMode(DataMatrixEncodeMode.FULL);
		}

Kind regards
Matthias

Hello,

may be this is the right code?

generator = new BarcodeGenerator(barcodeType, barcodeValue);
generator.getParameters().getBarcode().getPadding().getTop().setMillimeters(0);
generator.getParameters().getBarcode().getPadding().getBottom().setMillimeters(0);
generator.getParameters().getBarcode().getPadding().getLeft().setMillimeters(0);
generator.getParameters().getBarcode().getPadding().getRight().setMillimeters(0);
generator.getParameters().getBarcode().getCodeTextParameters().setLocation(CodeLocation.NONE);

		if (EncodeTypes.DATA_MATRIX.equals(barcodeType))
		{
			generator.getParameters().getBarcode().getDataMatrix()
				.setDataMatrixEncodeMode(DataMatrixEncodeMode.FULL);
		}

Kind regards
Matthias

@curmas,
Yes, this is the right code while using the latest library. For more details please visit the following articles:

Set Barcode image padding
How to create Datamatrix Barcode
Control the Appearance of Code Text

Thanks a lot