web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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();

I have the same question (0)
  • Martin Dráb Profile Picture
    237,978 Most Valuable Professional on at

    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.

  • 0dynTheMutant Profile Picture
    10 on at

    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
    237,978 Most Valuable Professional on at

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

  • Suggested answer
    0dynTheMutant Profile Picture
    10 on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans