cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
markslosberg
Resolver II
Resolver II

PDFviewer - Displaying a PDF stored on SharePoint or OneDrive

Over the summer I built an app that was easily able to display a PDF stored either on OneDrive or SharePoint by creating an app that loaded the file as a blob into a Context Variable as a Blob.  It worked perfectly by referring to the context variable PDFviewer1.jpg

PDFviewer2.jpg

Many months later, I am trying to use that technique and it isn't working.  Does anyone know if support for this technique is no longer available?  The file is stored on my OneDrive and this should be simple.

 

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
markslosberg
Resolver II
Resolver II

I gave up for the moment although I have enlisted the help of a variety of Microsoft resources including the support channel and others in the product team to answer the central question of how to correctly display a PDF stored in OneDrive in the PDFViewer control.

 

I developed a workaround by:

  1. adding a field of type "File" to the CDS entity - (you may note that there is now an Image type field too.  I tried that and it didn't work.  I just haven't deleted it yet;-). markslosberg_2-1610174236978.png
  2. adding a step in the Flow that creates the PDF to upload the "file content" of the CreatePDFfromWordDoc flow step to the new CDS field. 
     
     
     
     
    image.png

     

  3. Then I was able to successfully refer to that selected record from the record selected from a gallery pointed to the CDS entity.  By using the .Value from the selected record/field as the input to the Document parameter in the PDF Viewer, I got it to correctly display the PDF.  markslosberg_1-1610174063989.png

Definitely "going around the block to get next door" but in the end it is probably a better design and will minimize runaway "intermediate" or dated versions of the printed document accumulating in the OneDrive folder. 

 

I don't have time to solve the original question as it stands which remains, "can one display a PDF stored in a OneDrive or SharePoint Document library in a PDFViewer control?"  I just don't know but hopefully, someone with deep product knowledge can answer that question.  In the meantime, I have an effective workaround, and perhaps a better overall design.

I probably could have also gotten an Azure Storage account and used it to store the PDF temporarily to display it but that would be even clunkier and heavy-handed, plus my client hasn't committed to any Azure usage so far so that would have meant a lot of other lengthy discussions that I wanted to avoid.

 

My only fear is that I have been using the PDFViewer control now for just about 4 years and it is still classified as "Experimental" image.png. This approach, syntax and usage is not sanctioned in the documentationimage.png 

as a supported input to the Document property.  That states that the input to the Document property of the PDFViewer control is supposed to be only a direct https:// link to an unsecured URL with no redirects.  I worry that 6 months ago from now something will change and suddenly this won't work then like my solution from 6 months ago doesn't work now but I will cross that bridge when I get to it.  In the meantime, this looks like a pretty stable workaround but we will see as we test it with some 100 users or so.

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@markslosberg 

What is your formula for defining the pdfobject variable?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Here is the OnSelect code that runs on this button

UpdateContext(
    {
        pdfobject: 'CreateWordPDFQuote-outsideofsolution'.Run(
            "FGSO-1143",
            "testfilefromAppOutsideSolution"
        )
    }
)

Here is the Flow that is called (all that is missing is the initial PowerApp Init step).

markslosberg_0-1610052707156.png

 

And here is the money steps at the end expanded (ignore the pdfURL - that is just and experiment that isn't working)but everything else is correct.

markslosberg_1-1610052898605.png

Here is context variable in PowerApps

markslosberg_2-1610052983663.png

And here is the contents of pdfobject after I run the flow.

markslosberg_3-1610053028911.png

Here is the OneDrive folder that contains the file:

markslosberg_4-1610053269277.png

And here is a sample PDF quote that I am generating:

markslosberg_5-1610053396695.png

 

As I said, I had this design pattern working perfectly over the summer and now that I actually need it to work as a "last mile" feature, I am stymied.

 

Thanks for your help.

 

markslosberg
Resolver II
Resolver II

I gave up for the moment although I have enlisted the help of a variety of Microsoft resources including the support channel and others in the product team to answer the central question of how to correctly display a PDF stored in OneDrive in the PDFViewer control.

 

I developed a workaround by:

  1. adding a field of type "File" to the CDS entity - (you may note that there is now an Image type field too.  I tried that and it didn't work.  I just haven't deleted it yet;-). markslosberg_2-1610174236978.png
  2. adding a step in the Flow that creates the PDF to upload the "file content" of the CreatePDFfromWordDoc flow step to the new CDS field. 
     
     
     
     
    image.png

     

  3. Then I was able to successfully refer to that selected record from the record selected from a gallery pointed to the CDS entity.  By using the .Value from the selected record/field as the input to the Document parameter in the PDF Viewer, I got it to correctly display the PDF.  markslosberg_1-1610174063989.png

Definitely "going around the block to get next door" but in the end it is probably a better design and will minimize runaway "intermediate" or dated versions of the printed document accumulating in the OneDrive folder. 

 

I don't have time to solve the original question as it stands which remains, "can one display a PDF stored in a OneDrive or SharePoint Document library in a PDFViewer control?"  I just don't know but hopefully, someone with deep product knowledge can answer that question.  In the meantime, I have an effective workaround, and perhaps a better overall design.

I probably could have also gotten an Azure Storage account and used it to store the PDF temporarily to display it but that would be even clunkier and heavy-handed, plus my client hasn't committed to any Azure usage so far so that would have meant a lot of other lengthy discussions that I wanted to avoid.

 

My only fear is that I have been using the PDFViewer control now for just about 4 years and it is still classified as "Experimental" image.png. This approach, syntax and usage is not sanctioned in the documentationimage.png 

as a supported input to the Document property.  That states that the input to the Document property of the PDFViewer control is supposed to be only a direct https:// link to an unsecured URL with no redirects.  I worry that 6 months ago from now something will change and suddenly this won't work then like my solution from 6 months ago doesn't work now but I will cross that bridge when I get to it.  In the meantime, this looks like a pretty stable workaround but we will see as we test it with some 100 users or so.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,769)