Other alternate ways 😁
This following one statement in the Document property on a PDF Viewer control will dynamically convert many document types to PDF you can display in your apps such as Word documents, PowerPoint presentations, HTML files. Loads more.
Substitute( Gallery1.Selected.Thumbnail, "transform/thumbnail", "transform/pdf" )
There is a more consistent way of doing it with PDF documents using the Graph APIs which surface a "@content.downloadUrl" property for any file, but this property in particular works 100% of the time, and once again you only need to set the Document property on the PDF Viewer to this field using the PA_Graph_DriveItems Flow I've shared on a really long blogs that speaks to loads more things you equally do using those APIs.
Rather download the simplified version of demo app I've shared on that blog, and all the other Flows if you want to:
@CuriousJ wrote:
Hi Brian,
I have below error when adding the variables to powerapps. Not too sure where I did wrongly. Pretty new to the powerapps and flow. Maybe you could share some insight. Thanks.
I have correct the code in OnVisible property on the second screen in the app as it should have actually referenced the original document file name and not "._dlc_DocIdUrl_Description" (my bad ).
The correct code for the OnVisible property should in fact be as follows:
UpdateContext({ loading_v: true });
UpdateContext({
pdf_v: 'PowerApps-GetPDFdocument'.Run(
Concatenate( First( Split( selecteditem_v.Name, ".") ).Result, ".pdf")
)
});
UpdateContext({ loading_v: false })
The purpose of the "Split" function used in the code above is to remove the file name extension of the original document name and thereaafter replace it with a ".pdf" file extension name.
Hope that solves the issue you were experiencing.
I have updated that blog with the correct code as well.
Based on your screenshots it would appear the problem lies in your PowerApp and not with the Flow. I'd also suspect that there is nothing wrong with any of your code on the second screen.
I'll need to retest the code because the way in which I populated the rows in my own gallery was actually using a Flow that returned the "._dlc_DocIdUrl_Description" property of the document. In which case in the next couple of days I'll update that blog in the next few days that details the first Flow I used to populate my Gallery with the PDF documents stored on your SharePoint Library...
Hi @CuriousJ,
Further to checking if the Flow did successfully run, should you find it didn't even attempt to run, I'd suggest removing that Flow from the app and then add it again and test again.
Please share your findings, perhaps I can help further with more details.
Regards,
Brian
I wrote that blog and I am curious how many App Makers out there tried the "hack" I used asa for me at least it appeared to work consistantly well with any PDF document I wanted to view based on that Flow.
Having said that, subsequent to writing that blog I have been working on an "awesome" demo app that amongst many other things demostrates a technique to view any PDF document in SharePoint in 100% totally supported ZERO HACK method <grin> by running a single Flow not multiple times for say each PDF document in a folder in a Document Library but just once for all PDF documents in that single folder. Based on the technique I leveraged in my upcoming blog, my personal personal opinion is that PowerApps team may well finally have a fully supported method to finally enable this functionality natively within PowerApps (if they not already working on it...).
A few weeks ago I posted a teaser / prototype demo of the type of functionality this demo app implemented with just one screen can do:
Watch this space - within the next 2 weeks latest.
Hi @CuriousJ ,
Please go to your flow's history, then check if the flow returns a proper PDF File content back to your app.
Best regards,
Hi @CuriousJ ,
Do you want to preview the PDF files stored in your SP Library?
If you want to preview the PDF files stored in your SP Library, I afraid that there is no direct way to achieve your needs in PowerApps currently. The PDF Files (or any other files) stored in a SP Library is required to authenticate, but if you want to preview PDF files in PDF Viewer control, the server that hosts the document must not require authentication.
Please check the limits in PDF Viewer control, please check the following article:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-pdf-viewer#limitations
As an alternative solution, I think the combination of PowerApps and MS Flow could achieve your needs. Please check and see if the following blog and video resources would help in your scenario:
https://masteroffice365.com/viewing-pdfs-from-sharepoint-within-powerapps/
https://www.youtube.com/watch?v=NTp77benqfQ
Please take a try with above solution, then check if it could help in your scenario.
Best regards,
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional