The Syncfusion PDFViewer code component is a versatile tool for viewing PDF files directly in your application. It supports loading files from multiple sources, including URLs and Base64 strings. This guide walks you through the process of retrieving and displaying a file stored in Dataverse in the PDF Viewer component using Power Automate.
To store files in Dataverse, you’ll need to set up a table with a file column. Follow the instructions in Create a new Dataverse table with file column.
-
Set Up a PowerApps Canvas Application: Follow the steps in Create a PowerApps Canvas application to set up your app. And then Import PdfViewer Code Component in the newly created Canvas application.
-
Access Power Automate Tab: In Canvas application, click
Power Automate
from the left navigation pane in the PowerApps portal in three dots menu. -
Create New Flow: In that, click on
Create new flow
and select+ Create from blank
option. -
Name Your Flow and Add Input: Rename the flow to
GetFileFromDataverse
. In thePowerApps v2
step, click Add an input, chooseText
, and name the variableID
. -
Retrieve the File from Dataverse: Add the Download a file or an image action from Dataverse. Select the table (
SF Files
), file column (File
), and input variable (ID
) as the Row ID. Rename the step asFile
. -
Set Up the Output: Add the Respond to a Power App or flow action. Add an output of type
Text
and use the following expression to fetch file content:body('File')?['$content']
-
Save and Load the Flow: Click
Save
to finalize your flow. Ensure the flow is accessible in your PowerApps canvas application by loading it through thePower Automate
tab.
-
Add a Gallery for File Selection: In your PowerApps Canvas application, insert a Vertical Gallery control and connect it to the
SF Files
table. Set theOnSelect
property of the gallery to trigger the flow using this expression:Set( DataverseFile, GetFileFromDataverse.Run( Match( Gallery1.Selected.File.Value, "rows/(?<value>[^/]+)/fileimageurl" ).value ) );
-
Configure the PDF Viewer: Add the SfPdfViewer component to your app layout. Set the Document property to load the file content using:
DataverseFile.filecontent
-
Preview the Application: Click the
Preview
button in the PowerApps portal. Select a file from the gallery to display it in the PDF Viewer component.