Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

Can't print barcodes on pdf from the 2nd file

Posted on by 1,085

Hi everyone,

i need to print a large amount of pdf files (100 or more) containing barcodes. I've got a class which calls the report many times inside a while loop, something like this:

PrintJobSettings              printJobSettings = new PrintJobSettings();
Args                                    args;

ReportRun                               reportRun;
Report                                  report;

while select custTable where ...

{

            args = new Args(ReportStr(MyReport));
            args.caller(this);

            //report parameters
            args.parm(custTable.AccountNum);

            reportRun = new ReportRun(args);

            report = reportRun.report();
            report.interactive(false);

            printJobSettings = reportRun.printJobSettings();
            printJobSettings.setTarget(PrintMedium::File);
            printJobSettings.format(PrintFormat::PDF_EMBED_FONTS);
            printJobSettings.fileName(path   custTable.AccountNum   '.pdf');

            printJobSettings.lockDestinationProperties(true);
             reportRun.run();

}

The issue is everything works fine for the first pdf file it prints, but from the 2nd file it starts to mess up the barcodes: it shows symbols and letters instead of the barcode image:

errore.jpg

The right version (as in the first file it prints) should be:

7737.ok.jpg

To make it work I have wrote a job to print a single file and I launch it manually several times. This is the only way I found to make it work properly, but it's not a good solution.

Anyone experienced the same issue and have found some workaround to manage it?

Thank you in advance

regards

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,419 on at
    RE: Can't print barcodes on pdf from the 2nd file

    Hi,

    Can you not do the printJobSettings Inititialization in the while loop as well? Please try this code -

    PrintJobSettings                        printJobSettings;
    Args                                    args;
    
    ReportRun                               reportRun;
    Report                                  report;
    
    while select custTable where ...
    
    {
    
                args = new Args(ReportStr(MyReport));
                args.caller(this);
    
                //report parameters
                args.parm(custTable.AccountNum);
    
                reportRun = new ReportRun(args);
    
                report = reportRun.report();
                report.interactive(false);
    
                printJobSettings = new PrintJobSettings();
    
                printJobSettings = reportRun.printJobSettings();
                printJobSettings.setTarget(PrintMedium::File);
                printJobSettings.format(PrintFormat::PDF_EMBED_FONTS);
                printJobSettings.fileName(path   custTable.AccountNum   '.pdf');
    
                printJobSettings.lockDestinationProperties(true);
                 reportRun.run();
    
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans