Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Print SSRS Report through printer

Posted on by 742

Hi Everyone, 

Using below code I am able to save PDF copy of my SSRS report.

But I want to get direct print of my PDF copy without saving it to directory.

What change shall I make in main method of Controller class?

public static void main(Args _args)
{
#define.ReportDesign("CHI_GenerateRecLabelMobReport.Report")
CHI_GenerateRecLabelMobController generateRecLabelMobController;

//
SRSPrintDestinationSettings printerSettings;
//

generateRecLabelMobController = new CHI_GenerateRecLabelMobController();

generateRecLabelMobController.parmReportName(#ReportDesign);

generateRecLabelMobController.parmArgs(_args);

generateRecLabelMobController.parmShowDialog(false);

//link the printer settings to the controller
printerSettings = generateRecLabelMobController.parmReportContract().parmPrintSettings();
//print to pdf and always overwrite if the file exists
printerSettings.printMediumType(SRSPrintMediumType::File);
printerSettings.fileFormat(SRSReportFileFormat::PDF);
printerSettings.overwriteFile(true);
printerSettings.fileName(@"C:\\test.pdf");

//run & save the report
generateRecLabelMobController.startOperation();

}

Thank you on advance.

  • Verified answer
    István Orosz Profile Picture
    István Orosz 2,137 on at
    RE: Print SSRS Report through printer

    The SRSPrintDestinationSettings class is able to direct a physical printer, tray, etc. Be sure that the printer is available on the target machine, also check the print management setup in AX.

  • Rhushikesh R Profile Picture
    Rhushikesh R 742 on at
    RE: Print SSRS Report through printer

    Hi Martin,

    I agree with you.

    But instead of File if I write below code

    printerSettings.printMediumType(SRSPrintMediumType::Printer);

    printerSettings.printerName("123");

    generateRecLabelMobController.parmExecutionMode((SysOperationExecutionMode::Synchronous));

    Will this work?

    Or I have to make more changes?

    My requirement is if I pass Printer Name specified in

    Warehouse Management > Setup > Document Routing > Document Routing

    in my controller class then my SSRS report should get printed through that Printer.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: Print SSRS Report through printer

    To print the report, use SRSPrintMediumType::Printer instead of SRSPrintMediumType::File.

  • Rhushikesh R Profile Picture
    Rhushikesh R 742 on at
    RE: Print SSRS Report through printer

    Hi Andre,

    Actually I want to print the report directly through printer.

    My actual requirement has been written on below link,

    community.dynamics.com/.../1000500

    As I am new to AX world, I am not getting what changes shall I make in my Controller class to get the Print of report directly through specified name of Printer.

    I would be thankful to you if you help me out.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: Print SSRS Report through printer

    Rhushikesh,

    If you need to print it, why are you saving it as a file? Or do you need both? Can you explain the scenario?

    Theoretically, you can try to open Adobe reader using its API, load the document and print it. Or print the report twice from your coding: once for creating the pdf file and one for printing it.

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans