Free Support Forum - aspose.com

PDF417 of fixed height

Hi all,
I need to generate PDF417 barcodes setting XDimension different from ‘Auto’ and keeping a fixed barcode height.
I can fix barcode height setting property ‘Barcode.BarCodeHeight’ property, but this works if AutoSizeMode is set to Nearest.
On the other side I need to set AutoSizeMode to ‘None’ to make XDimension setting not be ignored…
How can I set a custom XDimension keeping a fixed height?

Thankyou very much!

Elisa Costa

@elisacosta

Thanks for providing us details.

Could you also share your sample code to evaluate your issue precisely, we will check it soon.

Yes for sure, here it is an example of what I’m trying to do:

BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Pdf417, “12345678”);

/* x-dimension is the smallest width of the unit of BarCode bars or spaces.
Increase this will increase the whole barcode image with.
Ignored if BarcodeParameters.AutoSizeMode is set to AutoSizeMode.Nearest or
AutoSizeMode.Interpolation*/

generator.Parameters.Barcode.XDimension.Pixels = 3;

/BarCode image height when BarcodeParameters.AutoSizeMode property is set to AutoSizeMode.Nearest or AutoSizeMode.Interpolation./
generator.Parameters.Barcode.BarCodeHeight.Pixels = 130;

// how can I make the previous two setting work together? Is it possible?
generator.Parameters.Barcode.AutoSizeMode = AutoSizeMode.None; // or Nearest??

Thanks a lot!

Best regards

Elisa Costa

@elisacosta,

Thanks for the sample code segment.

I tested your scenario/case using the following sample code and found the issue. I found an issue with with PDF417 barcode image height when AutoSizeMode to ‘None’, the height is not correct:
e.g
Sample code:

Aspose.BarCode.Generation.BarcodeGenerator generator = new Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.Pdf417, "12345678");
            /* x-dimension is the smallest width of the unit of BarCode bars or spaces.
            Increase this will increase the whole barcode image with.
            Ignored if BarcodeParameters.AutoSizeMode is set to AutoSizeMode.Nearest or
            AutoSizeMode.Interpolation*/

            generator.Parameters.Barcode.XDimension.Pixels = 3;

            //BarCode image height when BarcodeParameters.AutoSizeMode property is set to AutoSizeMode.Nearest or AutoSizeMode.Interpolation./
            generator.Parameters.Barcode.BarCodeHeight.Pixels = 130;

            generator.Parameters.AutoSizeMode = Aspose.BarCode.Generation.AutoSizeMode.None; //it does not work for height
            //generator.Parameters.AutoSizeMode = Aspose.BarCode.Generation.AutoSizeMode.Nearest;//it works and give the image with exact height.

            generator.Save("e:\\test2\\out.jpg", Aspose.BarCode.BarCodeImageFormat.Jpeg);

I have logged a ticket with an id “BARCODENET-37414” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@elisacosta,

Parameter generator.Parameters.Barcode.BarCodeHeight is obsolete. Use generator.Parameters.ImageHeight instead. But it should be used in autosize modes only!

In your case if you want to use AutoSizeMode.None you should use:
generator.Parameters.Barcode.XDimension.Pixels = 3;
generator.Parameters.Barcode.BarHeight.Pixels = 130;

Please note that parameter generator.Parameters.ImageHeight (and obsolete parameter generator.Parameters.Barcode.BarCodeHeight as well) is ignored in AutoSizeMode.None mode.