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 Platform Community / Forums / Power Apps / view pdf in pdf viewer...
Power Apps
Answered

view pdf in pdf viewer control using base64

(0) ShareShare
ReportReport
Posted on by 30

Hello!

I have 3 screens.

 

1st screen is the login screen where customer can login with dynamics quote id and email.

2nd screen is the quote detail screen with details about the quote as well as the 'File Name' of the attached pdf to the respective quote which is store in Notes on the timeline of the quote in dynamics.

3rd screen has the pdf viewer control.

 

In the document property of the pdf control I have used : Text("data:application/pdf; base64, base64text...…..")

when I copy-paste the base64 string the pdf is displayed...

But I will not be able to do this because I need to view different pdf's.

 

How do I get the base64 string to that spot?

 

Please help!

Thank you.

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    Hi @praneepradee ,

    The code below gets a PDF file selected in a gallery (from a SharePoint Library) and displays in in the PDF viewer. As far as I am aware, this is the only way of selecting a file and viewing it.
    Firstly at App OnStart, set a Variable to the base address of your site and folder path.

    Set(
     stSite,
     "https://xxxxxx.sharepoint.com/sites/xxxxxx"
    );
    Set(
     stFolder,
     "xxxxxxx/" //your folder path
    )

    Make a Flow (mine is PDFView) that does this PDFFlow.png

     

     

     

     

     

     

     

     

     

     

     

     

     

    Then this code is launched from the gallery item

    Set(
     stPDFName,
     ThisItem.DocName //my field name
    );
    Set(
     ViewPDF,
     PDFView.Run(
     stSite,
     Concatenate(
     "/",
     stFolder,
     First(
     Split(
     stPDFName,
     "."
     )
     ).Result,
     ".pdf"
     )
     )
    )

    Finally the Document in your PDF viewer will be

    ViewPDF.pdf

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • praneepradee Profile Picture
    30 on at

    Thank you for the answer sir.

     

    But when i'm able to display the pdf by pasting Base64 string. 

    There might be a possible way to get the base 64 string in:

     

    Text("data:application/pdf;base64, base64")

     

  • praneepradee Profile Picture
    30 on at

    Sir, I was able to view the pdf.

     

    This is the formula I've used:

     

    Concatenate("data:application/pdf;base64,",Lookup(Notes, Regarding in LookUp(Quotes,'Quote ID'= quoteinput.Text).quoteid).Document)

  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    Thanks @praneepradee ,

    I did understand your question - the Flow actually does this by getting the File Content and returning it to PowerApps.

    I can tell you that this method works well on PDF files in a SharePoint Library - you just have to send it the URL.

    I am glad you got it working - I will make a note of this as I have not seen this before

    Concatenate(
     "data:application/pdf;base64,",
     Lookup(
     Notes, 
     Regarding in LookUp(
     Quotes,
     'Quote ID'= quoteinput.Text
     ).quoteid
     ).Document
    )

    Where do you have this stored?

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • praneepradee Profile Picture
    30 on at

    @WarrenBelz 

     

    This application brings in a relationship between Dynamics 365 and PowerApps only. So I can't take help from SharePoint.

    Quotes and Notes are stored in Dynamics.

    I haven't used any flow as of such.

     

    The 'Document' has base64 text 

  • Romsteck Profile Picture
    83 on at

    Hello,

     

    I tried to paste the base64 string as following :

     

    "data&colon;application/pdf;base64," & <b64string>

     

    But PowerApps says "Make sure that the pdf file is coming from an https link".......

     

    How did you do ?

     

    I also used flow but that's slow and it's not really a best practice, it can't work offline so...

     

    Thanks in advance !! 😉

  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    Hi @Romsteck ,

    I was actually surprised that worked. The "prefix" of data&colon;application/pdf;base64," & <b64string> simply adds a "header" to "raw" Base64 text (which is a method of storing images as text), so it can be "resolved" and viewed in a Power Apps Image Control.

    However the Power App PDF viewer is something else. I have never been able to get one to work without a Flow - a simple one as below - taking a PDF file from a SharePoint Library (SharePoint is not relevant, but it needs to be a file).

    PDFFlow.png

  • Community Power Platform Member Profile Picture
    on at

    Hi Praneepradee, 

     

    Mind explaining a bit more how you got this to work with Dynamics, I am in a similar boat and not really understanding the code. Thank you! 

     

  • Michael Seerup Profile Picture
    173 on at
    Setting this value in Document in the PDF viewer worked for me. 
    "data&colon;application/octet-stream;base64," & varBase64String

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard