Barcode PDF417 MACRO Attributes lost

Hello,
I’ve written some code to use pdf 417 macro.
PNGs are generated but the consumer of the barcode tells me that the attributes (segment count, segment index) are missing.

using BarcodeGenerator barcodeGenerator = new(EncodeTypes.MacroPdf417);

barcodeGenerator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None;
barcodeGenerator.Parameters.Barcode.Pdf417.Pdf417ErrorLevel = Pdf417ErrorLevel.Level4;
barcodeGenerator.Parameters.Barcode.Pdf417.Columns = 13;
barcodeGenerator.Parameters.Barcode.Pdf417.Rows = 35;
barcodeGenerator.Parameters.Barcode.Pdf417.Pdf417CompactionMode = Pdf417CompactionMode.Binary;

barcodeGenerator.Parameters.Barcode.Pdf417.Pdf417MacroSegmentID = nCount;
barcodeGenerator.Parameters.Barcode.Pdf417.Pdf417MacroSegmentsCount = steps;

barcodeGenerator.CodeText = “Mass data …”;

barcodeGenerator.Save(“c:\temp\test.png”, BarCodeImageFormat.Png);

What’s the reason?

Regards

Jürgen

@juergen.debus,

I did evaluate your code segment using a few random values against Pdf417MacroSegmentID and Pdf417MacroSegmentsCount attributes. We appreciate if you could provide values for “nCount” and “steps” variables to evaluate your issue precisely. Moreover, please attach the current output PNG (by Aspose.BarCode for .NET) and your expected PNG. This will help us to find the issue accurately and to figure it out.

Thanks, below a complete code example.
Run it an you find the result in c:\temp
I can’t provide you with the expected result, this is part of the question :wink:

    private static void GenerateEchBarcodePdf417FromString(string bytesToEncode = "test", string ownerId = "123")
    {

        const int bytesPerBarcode = 500; // tbd ...
        int bytesToEncodeLength = bytesToEncode.Length;
        int steps = (int)Math.Ceiling(Convert.ToDouble(bytesToEncodeLength) / bytesPerBarcode);

        using BarcodeGenerator barcodeGenerator = new(EncodeTypes.MacroPdf417);
        barcodeGenerator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None;
        barcodeGenerator.Parameters.Barcode.Pdf417.Pdf417ErrorLevel = Pdf417ErrorLevel.Level4;
        barcodeGenerator.Parameters.Barcode.Pdf417.Columns = 13;
        barcodeGenerator.Parameters.Barcode.Pdf417.Rows = 35;
        barcodeGenerator.Parameters.Barcode.Pdf417.Pdf417CompactionMode = Pdf417CompactionMode.Binary;
      
        int bytesRemaining = bytesToEncodeLength;
        int bytesToRead = 0; 
        for (int nCount = 0; nCount < steps; nCount++)
        {
           
            barcodeGenerator.Parameters.Barcode.Pdf417.Pdf417MacroSegmentID = nCount;
            barcodeGenerator.Parameters.Barcode.Pdf417.Pdf417MacroSegmentsCount = steps;
            if (bytesRemaining >= bytesPerBarcode)
                bytesToRead = bytesPerBarcode;
            else
                bytesToRead = bytesRemaining;
            barcodeGenerator.CodeText = bytesToEncode.Substring(nCount * bytesPerBarcode, bytesToRead);
            bytesRemaining = bytesRemaining - bytesToRead;
            barcodeGenerator.Save(@"c:\temp\"+ownerId + "_"  + nCount + ".png", BarCodeImageFormat.Png);
         }

     }

@juergen.debus,
We have observed this issue and logged in our database for further investigation. You will be notified here once any update is ready for sharing.

This issue is logged as:
BARCODENET-37802 - MacroPdf417SegmentID and MacroPdf417SegmentsCount not set properly

ISO-IEC-15438-2006.pdf (1.0 MB)

Main problem here is MacroPdf417 requires two fields (ISO/IEC 15438:2006 Annex H Macro PDF417) Pdf417MacroFileID and Pdf417MacroSegmentID. Without them barcode cannot be encode as MacroPdf417. I updated internal documentation and this will published in next release. Currently you should manually set any positive number to Pdf417MacroFileID.

BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.MacroPdf417, "12345");
generator.Parameters.Barcode.Pdf417.Pdf417MacroSegmentID = 1;
generator.Parameters.Barcode.Pdf417.Pdf417MacroFileID = 10;

BarCodeReader read = new BarCodeReader(generator.GenerateBarCodeImage(), DecodeType.MacroPdf417);
BarCodeResult[] results = read.ReadBarCodes();
Console.WriteLine("MacroPdf417FileID: " + results[0].Extended.Pdf417.MacroPdf417FileID + " MacroPdf417SegmentID: " + results[0].Extended.Pdf417.MacroPdf417SegmentID.ToString());