Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Save report to pdf file - problem with opening using c# application

(0) ShareShare
ReportReport
Posted on by 10

Hi

I try to save/export AX 2009 report to pdf file using ReportRun class. Its working fine but when i try to open this pdf in custom c# application i got error - "Pdf file is damaged or protected with not specified encryption". 

If we'r using Adobe to open same report its working fine. Is there any encryption added saved/exported pdf like that? 

Code I use to save report : 

....
ReportRun    rr;
...

_args.name(ReportStr("ReportName"));
_args.record(selectedRecord);

rRun = new ReportRun(_args);
rRun.query().interactive(0);
rRun.report().interactive(0);
rRun.printJobSettings().fileName(@"Directory path + PdfFileName");
rRun.printJobSettings().setTarget(Printmedium::File);
rRun.printJobSettings().format(PrintFormat::PDF);
rRun.run();

  • Suggested answer
    0dynTheMutant Profile Picture
    10 on at
    RE: Save report to pdf file - problem with opening using c# application

    Yes, it is.

    I just found workaround of this problem, but main problem remains unresolved.

    I added rRun.printJobSettings().outputToPrnFile(true); and now report is printed insted of be saved to pdf file. Now everythink works fine.

    Stil i've got not idea why saveing report as pdf file is not working properly for me :/

    -----

    ....

    ReportRun    rr;

    ...

    _args.name(ReportStr("ReportName"));

    _args.record(selectedRecord);

    rRun = new ReportRun(_args);

    rRun.query().interactive(0);

    rRun.report().interactive(0);

    rRun.printJobSettings().fileName(@"Directory path + PdfFileName");

    rRun.printJobSettings().setTarget(Printmedium::File);

    rRun.printJobSettings().format(PrintFormat::PDF);

    rRun.printJobSettings().outputToPrnFile(true);

    rRun.run();

    -----

    Thanks for respond Martin

  • Martin Dráb Profile Picture
    232,982 Most Valuable Professional on at
    RE: Save report to pdf file - problem with opening using c# application

    Surprisingly, this seems to be the only place on internet where this error message is mentioned. Is it the exact wording?

  • 0dynTheMutant Profile Picture
    10 on at
    RE: Save report to pdf file - problem with opening using c# application

    Hi, thanks for respond. I did it already but it seems to be everything fine in c#. Is there any specific format for this file ( i mean report saved as pdf? ). I'm using most popular library to load and open file in c# app. 
    Update: When i open it in adobe and save as sample.pdf aplication can open report without any problems

  • Martin Dráb Profile Picture
    232,982 Most Valuable Professional on at
    RE: Save report to pdf file - problem with opening using c# application

    If it works in Adobe Reader, it seems that the problem is in your C# code and not in the file.

    Consider getting your code reviewed in a C# forum.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,241 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,982 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans