Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Print PDF from File Column in Dataverse

(3) ShareShare
ReportReport
Posted on by 30
Hi Guys,
 
do you have any idea about how to print PDF from File Column in Dataverse? It can be downloaded but before download, we want to print PDF directly from Canvas app Edit form or Model driven app main form.
 
thank you
Hannah
Categories:
  • HH-22102055-0 Profile Picture
    HH-22102055-0 30 on at
    Print PDF from File Column in Dataverse
    Again thank you very much for your expertise.
    Unfortunately, there is not URL for the PDF stored in File column in Dataverse. That's the hurdle of this print function.
     
    The file column has download function coming out of box. But the end user prefer to print before downloading as they download with the final purpose of printing and then deleting the downloaded copy. So if they can print directly from model driven app, that'll be much better. 
     
    There is an experimental control 'PDF viewer' which resolved the view/display PDF content feature. 'PDF viewer' is used in that canvas app embedded in main form of Model Driven app. But according to the limitations of 'PDF viewer', it doesn't support printing currently. therefore, when I tried print() power fx function in that canvas app, it doesn't work, just showing a blank of sheet paper. 
     
    So, the options 2 and 3 are good to explore but I am not that confident though. Option 4, I was trying to find any PCF from PCF gallery but no right solution there. 
     
    Anyway, a big thanks to you.
     
  • Suggested answer
    Daivat Vartak (v-9davar) Profile Picture
    Daivat Vartak (v-9d... 1,462 Super User 2025 Season 1 on at
    Print PDF from File Column in Dataverse
    Hello HH-22102055-0,
     

    You're looking to print a PDF directly from a File column in Dataverse, either within a Canvas app or a Model-driven app, without requiring the user to download it first. This is a common requirement, but it's not a straightforward process due to browser security restrictions. Browsers generally prevent websites (including your apps) from directly printing content from arbitrary URLs without user interaction (like clicking a download button).

    Here's a breakdown of the challenges and possible approaches:

    Challenges:

    • Browser Security: As mentioned, browsers restrict direct printing from URLs without explicit user action. This is a security measure to prevent websites from silently printing unwanted content.

    • PDF Rendering: The PDF needs to be rendered in a way that the browser's print functionality can access it.

    •  

    Possible Approaches (with Caveats):

    1. IFrame Approach (Canvas Apps and Model-driven Forms - Simpler, but limitations):

      • How it works: You can embed an iframe in your app and set the src attribute of the iframe to the URL of the PDF file in Dataverse. Then, you can use JavaScript to trigger the iframe's print functionality.

      • Caveats:

         
        • Cross-Origin Restrictions: If your Canvas app or Model-driven app and your Dataverse instance are on different domains, you might run into cross-origin resource sharing (CORS) issues. You'll need to configure CORS on your Dataverse instance to allow your app's domain to access the PDF files.
        • User Interaction: Even with an iframe, you might still need some user interaction (like clicking a button) to initiate the printing due to browser security. Silent, automatic printing is usually blocked.
        • Styling: Controlling the styling of the printed PDF can be challenging with iframes.
    2. PDF.js or Similar Library (Canvas Apps - More Control):
      • How it works: You can use a JavaScript library like PDF.js (provided by Mozilla) to render the PDF directly within your Canvas app. This gives you more control over the PDF display and printing.
      • Caveats:
        • Complexity: Integrating a PDF rendering library requires more development effort.
        • Performance: Rendering large PDFs can be resource-intensive, especially on mobile devices.
    3. Server-Side PDF Generation (Most Robust, but complex):
      • How it works: You could create a custom API (e.g., using Azure Functions or Power Automate) that fetches the PDF from Dataverse, generates a print-friendly version (if needed), and then returns it to your app. This bypasses some of the browser restrictions.
      • Caveats:  
        • Complexity: This is the most complex approach, requiring server-side development.
        • Cost: Using Azure Functions or other serverless services might have associated costs.
    4. Third-Party PDF Viewers/Printers (Explore):

       

      • Check AppSource: Explore the Dynamics 365 Marketplace (AppSource) for any third-party PDF viewer or printing solutions that might offer direct printing from Dataverse.
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • HH-22102055-0 Profile Picture
    HH-22102055-0 30 on at
    Print PDF from File Column in Dataverse
    Thank you @ArchitectMadhan. I tried PDF() but unfortunately it's not working so far. A big thank you!
  • Suggested answer
    ArchitectMadhan Profile Picture
    ArchitectMadhan 67 on at
    Print PDF from File Column in Dataverse
    Hi,
     
    There is a new feature available in PowerApps called PDF function but it is existing in the experimental mode. Please check the below link to know how to enable it in your canvas app.
     
     
    If you find this solution useful, please like it and accept it as answer.
    -ArchitectMadhan

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,286 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,064 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans