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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Send pdf to printer

(0) ShareShare
ReportReport
Posted on by 260

Hello guys,

Recently, I asked a question about how to print pdf to a printer. The link for reference is below.
https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/426717/print-memorystream-to-screen-or-any-printer

I managed to convert it to memory stream and send to a printer, but what I didn't realize is that the solution provided is only working for me when Adobe is installed otherwise it fails.

Also, it opens adobe every time to send to the printer.

Anyone have any other approach or a way to fix this solution to not open adobe when the code is executed?

    public static void sendPdfToPrinter(str _docName, str _printerName, str _base64Str, str _printerPath)
    {
        SRSPrintDestinationSettings srsPrintDestinationSettings = new SRSPrintDestinationSettings();
        srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::Printer);
        srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF);
        srsPrintDestinationSettings.printerName(_printerName);
        srsPrintDestinationSettings.printerWhere(_printerPath);
        srsPrintDestinationSettings.numberOfCopies(1);
        srsPrintDestinationSettings.collate(false);
        srsPrintDestinationSettings.printOnBothSides(SRSReportDuplexPrintingSetting::None);
        srsPrintDestinationSettings.printAllPages(true);
        srsPrintDestinationSettings.fromPage(0);
        srsPrintDestinationSettings.toPage(0);

        System.IO.MemoryStream stream = Binary::constructFromContainer(BinData::loadFromBase64(
            _base64Str)).getMemoryStream() as System.IO.MemoryStream;

        if (stream)
        {
            DocumentContract documentContract = DocumentContractFactory::Instance.Create(DocumentContractType::Pdf);
            documentContract.Name = _docName;
            documentContract.Contents =  stream.ToArray();
            documentContract.TargetType = TargetType::Printer;
            documentContract.Settings = srsPrintDestinationSettings.printerPageSettings();
            documentContract.ActivityID = newGuid();
            SrsReportRunPrinter::sendDocumentContractToDocumentRouter(documentContract);
        }
    }


Thanks,

I have the same question (0)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 698

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 698

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 567 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans