cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akorejwa
Frequent Visitor

How to use pdf viewer to view a pdf attachment in a list

I have a sharepoint list which may have multiple attachments associated with each item. Among these attachments, there will *always* be one for each item which will be useful for people in the field to view. I created a screen which displays some meta data and all attachments associated with the list item. However, I would like the user to either be able to select one of these and view it, or simply view the pdf that will be useful to people in the field (selection of the correct pdf attachment could be controlled by the name of the pdf perhaps?). There does not seem to be a 'onSelect' option for the attachments in the form that displays them.

How can I use pdfViewer to view a pdf attached to an item in a list?

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @akorejwa ,

I've afraid it's not supported to make this currently in PowerApps.

For now, you could only set the PDF viewer's Document to the PDF's link directly.Server redirects or HTML views of the document aren't supported. For example, set the Document to Gallery2.Selected.AbsoluteUri, it will not display PDF successsfully.

Here's a doc about PDF viewer for your reference:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-pdf-viewer

As an alternative way, I suggest you use the Lunch function.

Set the gallery's arrow's OnSelect: Launch(ThisItem.AbsoluteUri)

Then, if user click on the arrow, it will open PDF file in webpage automatically.742.png

 

 

Best regards,

Community Support Team _ Phoebe Liu

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
v-yutliu-msft
Community Support
Community Support

Hi @akorejwa ,

I've afraid it's not supported to make this currently in PowerApps.

For now, you could only set the PDF viewer's Document to the PDF's link directly.Server redirects or HTML views of the document aren't supported. For example, set the Document to Gallery2.Selected.AbsoluteUri, it will not display PDF successsfully.

Here's a doc about PDF viewer for your reference:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-pdf-viewer

As an alternative way, I suggest you use the Lunch function.

Set the gallery's arrow's OnSelect: Launch(ThisItem.AbsoluteUri)

Then, if user click on the arrow, it will open PDF file in webpage automatically.742.png

 

 

Best regards,

Community Support Team _ Phoebe Liu

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yutliu-msft ,

 

I'm new to power apps and I try to create an app based on some shp lists.

I have a shp list named receptions and it contains info about invoice details and product detalis and I also add pdf file to attachments column. On my screen I have a data table showing the info from my list, a gallery and a pdf viewer. 

What I want, if it is possible is if the user click on a data table row, pdf viewer should show the attachment it has. Even now I didn't find it how to do this, and I tried using a gallery. I've done what you said but it seems there is an error and I don't know how to solve it.

MF_powerapps_1-1604409712781.png

As you can see, the word AbsoluteUri is underlined with red. Same with pdf viewer Document propriety

MF_powerapps_2-1604409803324.png

 

What am I missing.

 

Please keep in mind I am a total noob in this so a tutorial on how to work this out is greatly appreciated.

 

Thank you!

 

@v-yutliu-msft , I think I found a way but it didn't fix my problem

 

I corrected the formula, and now it's working but it doesn't open into my pdf viewer but it opens a new tab in chrome showing the attachment. See image bellow 

MF_powerapps_0-1604411367128.png

Please help thanks !

  

Pramud
Frequent Visitor

First(Gallery1.Selected.Attachments).Value

Pramud_1-1612251744747.png

 

Pramud
Frequent Visitor

First(Gallery1.Selected.Attachments).Value

Pramud_0-1612251682061.png

 

finalfant111
New Member

I will take this one step further. In your case what Pramud said will work best, however, I have a solution that will allow you to select the PDF that you want to be shown, with the first one in list always showing by default.

 

1. Create your Gallery1 and Set the "On Select" to Set(SelectAttach,true)

2. Create a second Gallery2 in the middle of the Page or where ever you want. Set its visible property to the SelectAttach variable. Set it's OnSelect property to Set(SelectAttach,false)

3. This is the cool part. Since the attachments column in a Sharepoint list is also it's own table, it can be used as a Gallery's source. So set the Item property of Gallery2 to Gallery1.Selected.Attachments

4. Create a Label inside Gallery2 and Set its field to the DisplayName (it may already do this automatically by default when the label is added). Optional - create a button overlay so the finger pointer appears.

5. Now all that is left is set the PdfViewer's Document property to Gallery2.Selected.Value

 

This will make it so that when you select something in Gallery1, a "Popup" will appear that will show you a list of the attachments associated with the item selected in Gallery1. When you select the attachment, it will close the "Popup" windows and display the document in the PDFviewer. Pretty neat huh?

thanks @finalfant111 , it works like a charm.

@finalfant111 ,

 

What a beautiful solution, it works perfectly!! Just wanted to say thanks alot!!

 

👏👍

d_Larbalestier
Frequent Visitor

Great workaround @finalfant111

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,898)