Showing results for 
Search instead for 
Did you mean: 
Helper II
Helper II

PDF viewer not working

I have used this tutorial to convert a file into PDF online and then try to show that PDF in my app


But all I get is a grey box that states "Couldn't open PDF file", with a Link underneath "Open in my Browser instead" which works perfectly. I.e. the URL I give to the PDF viewer is definitely correct. 


The file I'm converting is a HTML file sitting in a Sharepoint Document Library. I'm working for a large corporation so I believe we are in a dedicated environment. Anyone got an idea what causes this issue and/or how to overcome it.


There is actually a very easy to use workaround 🤗


Assuming you have a Gallery control with the Items property set to a SharePoint Data Source for any given Document Library, all you need to do is set the Document property on the PDF Viewer control to:

Substitute (Gallery1.Selected.'{Thumbnail}'.Small, "transform/thumbnail", "transform/pdf" )


It doesn't really get any easy then that!

Try it and reply back on this thread if it works for you so other people also know...


I'm actually accessing an attachment in a SharePoint list entry, so currently the PDF viewer is pointing to:



Can your workaround be applied to this kind of approach?

No unfortunately there is no Thumnail property for List Item Attachments.


I did put an Idea forward for this so you may as well vote for it.


There are ways you can move the attachments from any List Item to a Document Library using a Flow trigger when the list item is created (with attachments), as per this example:

Genius. This seems to work, though not yet consistently but I will investigate why it fails occasionally. 

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:


View solution in original post

@MasterOffice365I marked your new answer as the solution, so that people can see that one straight away. I think the reason it isn't always working is that the thumbnails are not loaded immediately. could that be? I created the gallery and included the thumbnail in the individual gallery items but they are not there when I open my page, they only appear later. 

I think I jumped the gun a bit with my initial response insofar as using the Thumbnail property specifically for PDF documents.


The Thumbnail property works great for other types of documents, but for specifically for PDF documents the best technique is to use the "@content.downloadUrl" as is exposed using the PA_Graph_DriveItems flow and it's very easy to test and see how it works using the demo app I've shared in the blog I've posted.


In a nutshell what the PA_Graph_DriveItems flow does is return all the files and subfolders from a specific folder in a Document Library, initially the root folder, and you can then call the same flow again to return all the files and subfolders of any given subfolder in the root folder of the library. A little confusing initially, but the demo app should help you quiet a lot to follow the logic.


The PA_Graph_DriveItems flow includes a Send an HTTP request to SharePoint action that in turns queries the SharePoint v2 Graph driveItem API, which exposes the "@content.downloadUrl" for every file in that specific folder.


To quote:

Instance Attributes

"Instance attributes are properties with special behaviors. These properties are temporary and either a) define behavior the service should perform or b) provide short-term property values, like a download URL for an item that expires."

@microsoft.graph.downloadUrl  string .  . A URL that can be used to download this file's content. Authentication is not required with this URL. Read-only


The reason this property thus enables you to surface PDF documents directly in the PDF Viewer control is because the URL includes a temporary authentication token and accordingly the link to any PDF documents are pre-authenticated.


This is exactly what has always been the problem why "historically" PDF documents stored in SharePoint Document Libraries could not be displayed in the PDF Viewer control, because the URL links to the PDF documents stored in SharePoint were not authenticated. Now with this particular Graph API they are thanks to the @microsoft.graph.downloadUrl property the API exposes.


Hope that makes sense.

One last thing worth mentioning is that most of the Flows I've shared on my blog make use of a Response action which is deemed to be a Premium connector.


However given the Flow are exceedingly reusable, my understanding is that they should fall into the Power Automate per flow plan and as such that by all accounts shouldn't be all that costly for most organizations to leverage. But I can't speak for Microsoft on that, but it does state on their FAQ website:


"Power Automate per flow plan which enables organizations to implement flows with reserved capacity that serve teams, department, or the entire organization without having to license each end user. This plan starts at $500/month for 5 flows."


As well as:

**Non User Licenses ** Number of API requests / 24 hours

Power Automate per flow plan15,000 per flow


To be frank: I decided that I wasn't bright/good enough to get your other solutions implemented. I did import the flows and changed the Sharepoint path to my Sharepoint in each of them. But the demo app still only offers "teams /xyz" as option in the drop down and not my sharepoint. I have no clue how I get that to work.


I cleaned my other app a bit and it seems as if the substitute thumbnail now works better. 



Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group


Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (31,529)