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, ...
Answered

Print memoryStream to screen or any printer

(0) ShareShare
ReportReport
Posted on by 260

Hello guys,

The title is pretty straight forward. 
Let`s assume I have a Base64 string which came from a PDF.
How do I send it directly to the screen or to any printer?
Right now, I have a code that convert this Base64 to PDF and send the file to the user, but I want to print it directly.

    public void convertBase64ToPdf()
    {
        System.IO.MemoryStream memoryStream = Binary::constructFromContainer(BinData::loadFromBase64(
            base64Label)).getMemoryStream() as System.IO.MemoryStream;

        File::SendFileToUser(memoryStream, 'test.pdf');
    }


Any ideas?

Thanks

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    In my blog here MSDyn365FO. How-to send PDF document to a printer from X++ – ievgen's ax blog (wordpress.com) I show how to print a file from the attachments to a printer, to do this you need to convert it to a stream so you can reause this code. 

  • bois0155 Profile Picture
    260 on at

    Hello ievgen,

    I tried your code it works and it send to the printers using document routing.

    Do you have any idea how can I send it directly to the d365 screen?

    I tried to change your code to use printMediumType(SRSPrintMediumType::Screen)

    but didn't work

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Try

    Browser br = new Browser();

           str downloadUrl = File::SendFileToTempStore(_stream, _fileName, classstr(FileUploadTemporaryStorageStrategy), true);

           if (downloadUrl != '')

           {

               br.navigate(downloadUrl, true, false);

           }

  • bois0155 Profile Picture
    260 on at

    Just tried it, and it download the pdf file instead of opening a pdf preview or something to show on screen.

    I'm not sure what I want to do is possible though

    I'll keep with the printer option only for now

    Thanks

  • Martin Dráb Profile Picture
    239,099 Most Valuable Professional on at

    How your web browser deals with PDF files isn't the reponsibility of the web application. If you want to open PDF files in the browser rather then downloading them, configure your browser accordingly.

    For example, if you're using Firefox, open Settings, scroll down to Applications, put PDF to Search file types or applications, select Portable Document Format (PDF) and set Action to Open in Firefox.

  • bois0155 Profile Picture
    260 on at

    Thank you guys.

    I was expecting a way to open it like a SSRS report using the Pdf viewer from d365 or something related.

  • Martin Dráb Profile Picture
    239,099 Most Valuable Professional on at

    Aha, then "send it directly to the screen" means "showing the content of the file inside an F&O form", right?

    SrsReportViewerForm uses a special type of control (Report Viewer) for this purpose.

    A similar approach is used in document management, where DocuView form utilizes Document Viewer Container control. Maybe you would be able to reuse it.

  • bois0155 Profile Picture
    260 on at

    Yes, sorry to not be clearly enough.

    Thank you Martin I'll check it out

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 March 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 738

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 286 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans