cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

PDF Reader - Not able to view on https

Hi,

I'm trying to view a PDF file stored on a https server using PDF viewer control.

 

(https://docs.microsoft.com/en-us/powerapps/controls/control-pdf-viewer)

 

I'm facing following issue :

 

When the pdf URL is : https://myserver/my_file_name.pdf

 

I have a "grey screen" saying : "Impossible to open your PDF file, Open it in your web Brower"

 

When i open it in my web brower (using the same URL) it's working fine...

 

Control documention is saying something about "CORS" setting on the webserver (but i have no idea how/where i can check it on my webserver) :

 

If the PDF document resides on a server with restrictive CORS settings, you may not be able to 
view it within your app. To resolve this issue, the server that hosts PDF documents needs
to permit cross origin requests (CORS) coming from powerapps.com.

 

 

Does anyone faced same issue and find what settings to change on the webserver ?

 

Sorry for my english,

 

Thanks for reading.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: PDF Reader - Not able to view on https

Hi @Anonymous,

 

If the PDF document resides on a server with restrictive CORS settings, you may not be able to view it within your app. To resolve this issue, the server that hosts PDF documents needs to permit cross origin requests (CORS) coming from powerapps.com.

In case the document cannot be opened in PowerApps, the option to open the document in an external browser is presented to the end user. This option is also available in the control menu for all external documents.

 

For your reference:

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

 

Regards,

Mona

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

Re: PDF Reader - Not able to view on https

Hi @Anonymous,

 

If the PDF document resides on a server with restrictive CORS settings, you may not be able to view it within your app. To resolve this issue, the server that hosts PDF documents needs to permit cross origin requests (CORS) coming from powerapps.com.

In case the document cannot be opened in PowerApps, the option to open the document in an external browser is presented to the end user. This option is also available in the control menu for all external documents.

 

For your reference:

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

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Meneghino
Level 10

Re: PDF Reader - Not able to view on https

Please see here and vote for the idea if this helps:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/PDF-viewer-to-work-in-browser-even-with-URL-quer...

 

I am able to make the control work fine in Studio but not in the browser.  I will now try with the CORS settings to see if this fixes it.

Meneghino
Level 10

Re: PDF Reader - Not able to view on https

hi @v-monli-msft

I am working with Azure Blob Storage, what are the CORS settings needed?

I am asked for the following settings:

  • Allowed origins
  • Allowed verbs
  • Allowed headers
  • Exposed headers
  • Maximum age (seconds)

 

I have tried this, but it does not work:

  • Allowed origins: *
  • Allowed verbs: GET, HEAD, POST
  • Allowed headers: *
  • Exposed headers: *
  • Maximum age (seconds): 200

 

I am particularly confused in regards to headers...

 

Anonymous
Not applicable

Re: PDF Reader - Not able to view on https

Hi @v-monli-msft & @Meneghino,

Thanks for your answers.

 

I just tested the app in power apps client (not on the web editor) and result is pretty strange ^^

 

I can see pdf when using : 

http://myserver/my_file_name.pdf

 

But still same error when using :

https://myserver/my_file_name.pdf

 

@Meneghino i did some search about CORS and found below settings :

 

# Always set these headers.
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
 
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]

 

source : setting-cors-cross-origin-resource-sharing

(Honestly it's too deep for me but i hope it can help you...)

Highlighted
Super User
Super User

Re: PDF Reader - Not able to view on https

@v-monli-msft

 

I'm having this issue currently.  However, my data resides in the cloud in a Sharepoint Library.  The library was completely populated by MS Flow, which took files I had locally, copied them, renamed them, and populated the properties from other sources.  Flow did not have any trouble doing those actions.

 

My Powerapp has sucessfully retrieved data, and even written data back to the library (properties) without any errors.  However, when trying to view the files, which are PDF, in the PDF viewer, I get this error.  The PDF does properly view if I pick the "Open in my browser instead" link. 

 

I have no idea what CORS is, nor if I have any control over that in my office365 cloud-based Sharepoint site.  Please advise.

 

 

cholopa
Level: Powered On

Re: PDF Reader - Not able to view on https

Hi:

 

Anyone was able to solved this issue?

 

I'm able to see the pdf using the pdf experimental visor, but only with the webbrowser link.

 

pdf is in a sharepoint group, I supose the issue is coming from th "CORS setting", but don't know how to change it...

 

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

 

Anyone can help?

Super User
Super User

Re: PDF Reader - Not able to view on https

@cholopa,

 

Yess!!  You are in luck.  It took some time, and some collection of information in several posts, but I summarized the process here.  It is not intuitive, but it works great.  I have been using this for a long time, and have not had any problems with it.

 

https://powerusers.microsoft.com/t5/General-Discussion/How-To-procedure-on-how-to-view-a-PDF-file-fr...

 

Note:  Take VERY CLOSE attention to the base64() statement in the Respond to Powerapps action.  Its very strange, but that statement does NOT stick visually.  It IS there, but when you go back into your flow later, you may forget... like I just did an hour ago when I changed mine, found this post, with you wanting help!

 

Let me know if you  have questions.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Tomorrow, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 282 members 4,733 guests
Please welcome our newest community members: