Introduction
Power Apps now offers an experimental PDF Viewer control that lets you display PDFs directly within your app interface. This is especially helpful in use cases like displaying reference documents, training guides, or reports stored in SharePoint Document Libraries - without requiring users to download them.
Below is a detailed, step-by-step guide to help you display a PDF stored in SharePoint within your Power Apps application using the experimental PDF Viewer control.
Step-by-Step Instructions:
Step 1: Open or Create a Power Apps Project
- Navigate to https://make.powerapps.com.
- Either:
- Create a new Canvas app (start from blank), or
- Open an existing app where you want to display the PDF.
Step 2: Connect to SharePoint Document Library
- From the left panel, click on Data.
- Click on + Add data.
- Search for SharePoint and select it.
- Choose your account, paste or search for your SharePoint Site URL, and then click Connect.
- Select your Document Library where your PDFs are stored, then click Connect.
- (Optional) Open your SharePoint Document Library in a new tab and upload your PDF if it's not already available. This ensures the document can be linked and previewed in Power Apps.
Step 3: Insert the Experimental PDF Viewer
Step 4: Set Up PDF Viewer to Display a File
Start by using this formula in the Document property of the PDF Viewer:
LookUp(Documents, Name = "Sample PDF.pdf").'Link to item'Note: This may not always work as expected in Power Apps. If the PDF doesn't load, try the workaround method below to generate a direct file link.
Workaround: Generate a Direct PDF URL Manually
Sometimes Power Apps doesn't support rendering the default SharePoint link ('Link to item'). Instead, you can manually create a direct PDF link.
Steps to generate a working PDF link:
1. In SharePoint Document Library:
- Click on + Add Column > Select Hyperlink.
- Name it: Link
2. Once the column is created, go to Library Settings, then click on the Link column.
- Change Format URL as: from Hyperlink to Picture.
3. Back in your Document Library:
- Click on the ellipsis (...) next to the PDF file.
- Click Open in browser. The PDF opens in a new tab.
- Copy the full URL. Remove everything after .pdf so that the link ends with .pdf.
4. Go back to your document library and:
- Click on Edit in grid view.
- Paste this cleaned-up PDF URL into the Link column for that file.
- Click Exit grid view to save changes.
Finally, update the Document property of the PDF Viewer to reference your new link column:
LookUp(Documents, Name = "Sample PDF.pdf").Link
Pro Tips:
- Use Preview mode (F5) to test PDF rendering.
- Ensure your PDF link ends with .pdf - any additional query parameters or tokens may break it.
- This experimental control works best with direct-access or publicly accessible links.
Use Case Example:
This method is ideal for onboarding portals, document approval systems, training guides, or resource libraries where documents need to be viewed quickly without download.
Conclusion:
Embedding PDFs within Power Apps is now easier thanks to the experimental PDF Viewer control. With a direct SharePoint link configured properly, you can enable seamless in-app PDF viewing for onboarding guides, reference documents, and more - without needing third-party tools or downloads.
No comments:
Post a Comment