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

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

PDF not Loading in PDF Viewer on App start

(0) ShareShare
ReportReport
Posted on by 26
I created a document viewer application to view SharePoint library document in PDF Viewer in PowerApps. I followed Reza Dorrani video  https://www.youtube.com/watch?v=vqK29FWbLxU. The application is working fine. When I select a document in a gallery it shows the full document in PDF Viewer. I used the following code for Document property of the PDF Viewer 
If(
    Last(
        ForAll(
            Split(
                Gallery1.Selected.'File name with extension',
                "."
            ),
            {Result: ThisRecord.Value}
        )
    ).Result = "pdf",
   
    varLink & EncodeUrl(Gallery1.Selected.'Folder path' & Gallery1.Selected.'File name with extension'),
    Substitute(
        Gallery1.Selected.Thumbnail.Large,
        "/thumbnail",
        "/pdf"
    )
)
 
However, when app starts, it doesn't show any pdf in pdf viewer until I select one from the gallery. I want to show the last uploaded library document in pdf viewer when app starts. I would appreciate any help.
I have the same question (0)
  • Verified answer
    Mark Nanneman Profile Picture
    989 Super User 2025 Season 2 on at
    PDF not Loading in PDF Viewer on App start
    It probably isn't showing you anything until you select a gallery item, because your formula references the "Gallery1.Selected" property to get the file to display.

    Solution 1:  Set your gallery's default to "First(Self.AllItems)" or some formula that will LookUp the default PDF document you want to auto select.
    This will make it auto select this item on load.


    Solution 2: Use a variable to store the document you want to display, and set this automatically on the OnVisible property of your screen.


    You could use a variable to store your selected gallery item and reference that in your formula to display the pdf, and then on your screen's OnVisible property set that variable to a default record, i.e. "Set(varSelectDoc, First(<your_documents_data_source>))" or "Set(varSelectDoc, LookUp(<your_documents_data_source>,ID = <your_favorite_default_document_id>))"

    For your gallery you'd just have the OnSelect do "Set(varSelectDoc,ThisItem)"

    For your PDF formula just replace all "Gallery1.Selected." with "varSelectDoc."
     

    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff  |

     
  • MS-19111917-0 Profile Picture
    26 on at
    PDF not Loading in PDF Viewer on App start
    @Mark Nanneman, Thank you so much. Solution 2 resolved the problem. Really appreciate your help.
  • Mark Nanneman Profile Picture
    989 Super User 2025 Season 2 on at
    PDF not Loading in PDF Viewer on App start
    Any time!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 663 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 398 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 235

Last 30 days Overall leaderboard