web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

PDF Viewer

(0) ShareShare
ReportReport
Posted on by 295

Hi 

I've tried different solution I found regarding this but nothing worked. 

I would like to share a PDF file in PDF Viewer but I am getting this message instead. 

 

What should I add or change in order to display the file ( it is a pdf file for real) in the PDF Viewer? 

 

Carmen15_0-1718296193004.png

Thank you!

Categories:
I have the same question (0)
  • Verified answer
    MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi @Carmen15 

     

    The trick that you are using 

    Substitute(Gallery3.Selected.Thumbnail.Large,"/thumbnail","/pdf")

    only works with Office documents. It does not work with PDF files.

     

    This is an excellent video by Reza Dorrani that discusses how to set up a Document Viewer:

    https://www.youtube.com/watch?v=vqK29FWbLxU

     

    He explains how to use this formula for your "Document" property of the PDF Viewer control to render pdfs:

    If(
     Last(
     Split(
     Gallery3.Selected.'File name with extension',
     "."
     )
     ).Value = "pdf",
     //You need to watch this video and follow all the steps for PDF
     //https://youtu.be/vqK29FWbLxU?t=956
     //You have to add a "Pic" Column to the Document Library as HyperLink.
     //Set it manually to the file url using the Full Path
     //Change the "Pic" column to Picture.
     //Reza has Pinned the first Comment for the video from @DarrenCarlson. Make sure you read that
     Substitute(
     LookUp(
     Documents,
     Name = "DONOTREMOVE"
     ).Pic,
     "%252fShared%252520Documents%252fDONOTREMOVE.png",
     ""
     ) & EncodeUrl(Gallery3.Selected.'Folder path' & Gallery3.Selected.'File name with extension'),
     Substitute(
     Gallery3.Selected.Thumbnail.Large,
     "/thumbnail",
     "/pdf"
     )
    )

    Since the LookUp is not delegable, you may have issues with a large Document Library.

     

    -Mark

    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.

     

  • Carmen15 Profile Picture
    295 on at

    @MarkBandR thank you!!! it worked! 🙂 

    But I still have an issue. I am the only one that can see that PDF in PDF Viewer . The other users are not able. For them it is opening a black page saying "PDF file couldn't be open , make sure the PDF file is coming from an HTTPS link" 😞 

    How can I solve this ? 

    Thank you 

  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi @Carmen15 

     

    So down in the Comments section of Reza's video is the solution for this:

    https://www.youtube.com/watch?v=vqK29FWbLxU

     

    Users found that the "appres://" link was specific to the user id. If this link was hard coded, it would only work for the user that set it up. You need to make sure that this part of the code is dynamically changing:

     Substitute(
     LookUp(
     Documents,
     Name = "DONOTREMOVE"
     ).Pic,
     "%252fShared%252520Documents%252fDONOTREMOVE.png",
     ""
     )

    After reading the comments for the video I think it would be better to change the formula from a Substitute to this:

    First(
     Split(
     LookUp(
     Documents,
     Name = "DONOTREMOVE"
     ).Pic,
     "path=%252f"
     )
    ).Value & "path=%252f"

    Then it does not matter what your Document Library is named. The above code splits the "appres://" link at the "path=" spot so that you can set it to the file you want to see.

     

    To validate things look correct, put a Text Label on your form where users can see the entire thing. To start with just set the text to:

     LookUp(
     Documents,
     Name = "DONOTREMOVE"
     ).Pic

     

    You should get a value that starts with "appres://datasources/" if everything is configured correctly.

     

    Publish the app and have some users open the app. Have them grad the value of that label. If you compare the values of the text label, you should see then entire thing is the same except for one section that contains a guid identifying the user.

    MarkBandR_0-1718376019108.png

    If they are both the same then something is not setup correctly.

     

    This is the new more generic code for the Document property of the PdfViewer control:

    If(
     Last(
     Split(
     Gallery3.Selected.'File name with extension',
     "."
     )
     ).Value = "pdf",
     //You need to watch this video and follow all the steps for PDF
     //https://youtu.be/vqK29FWbLxU?t=956
     //You have to add a "Pic" Column to the Document Library as HyperLink.
     //Set it manually to the file url using the Full Path
     //Change the "Pic" column to Picture.
     //Reza has Pinned the first Comment for the video from @DarrenCarlson. Make sure you read that
     First(
     Split(
     LookUp(
     Documents,
     Name = "DONOTREMOVE"
     ).Pic,
     "path=%252f"
     )
     ).Value & "path=%252f" & EncodeUrl(Gallery3.Selected.'Folder path' & Gallery3.Selected.'File name with extension'),
     Substitute(
     Gallery3.Selected.Thumbnail.Large,
     "/thumbnail",
     "/pdf"
     )
    )

     

    If you have something different for the Document property, share it here and we can take a look.

     

    -Mark

     

     

     

  • adrn_wal Profile Picture
    7 on at

    adrn_wal_0-1719980939220.png

    I used Reza's formula, can you explain how this can happen? Thank you

  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi   @adrn_wal 

     

    Reza's video is great but at the time no one noticed that the link generated was user specific. In the post I made, I noted:

     //You need to watch this video and follow all the steps for PDF
     //https://youtu.be/vqK29FWbLxU?t=956
     //You have to add a "Pic" Column to the Document Library as HyperLink.
     //Set it manually to the file url using the Full Path
     //Change the "Pic" column to Picture.
     //Reza has Pinned the first Comment for the video from @DarrenCarlson. Make sure you read that

     

    Make sure you have done that if you are seeing that your App works for you (the person that created the App) and does not work for other users. 

     

    If you post a new question, I'm sure other users will join in to help if you are still having problems.

     

    -Mark

  • adrn_wal Profile Picture
    7 on at

    Thank you so much for your help

  • PG-31031202-0 Profile Picture
    2 on at
    Hello,
     
    I have watched the video on youtube but I am not able to find the pinned comment from @DarrenCarlson. I did try the code provided in the answer but I have some trouble adjusting it so that is works in my powerapp.
     
    I understand that this works for the person who created the powerapp, but not for others because of the ID. I just to not seem to understand how the code in the answer is solving this.
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard