Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

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

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
    0dynTheMutant 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
    Martin Dráb 230,235 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
    0dynTheMutant 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
    Martin Dráb 230,235 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans