cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MasterOffice365 Advocate II
Advocate II

Re: PDF viewer not working

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...

 

BungleBrain Helper I
Helper I

Re: PDF viewer not working

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

First(Gallery1.Selected.Attachments).AbsoluteUri

 

Can your workaround be applied to this kind of approach?

MasterOffice365 Advocate II
Advocate II

Re: PDF viewer not working

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.

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/View-thumbnail-images-of-List-Item-Attachments-...

 

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:

https://github.com/Office365Master/SPOThumbnails/blob/master/PowerApps-Move-ListAttachments-Document...

Maexchen Helper II
Helper II

Re: PDF viewer not working

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

MasterOffice365 Advocate II
Advocate II

Re: PDF viewer not working

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:

https://youtu.be/poKsDNYm9Jw

https://masteroffice365.com/powerapps/9/#DownloadSolution

 

View solution in original post

Maexchen Helper II
Helper II

Re: PDF viewer not working

@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. 

Highlighted
MasterOffice365 Advocate II
Advocate II

Re: PDF viewer not working

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.

MasterOffice365 Advocate II
Advocate II

Re: PDF viewer not working

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:

https://docs.microsoft.com/en-us/power-platform/admin/api-request-limits-allocations

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

Power Automate per flow plan15,000 per flow

 

Maexchen Helper II
Helper II

Re: PDF viewer not working

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

Announcements
secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (7,624)