HTMLview As PDF Viewer

I have a web app to display PDF content in a HTMLview. It is worked if URL is called at PC browser (google chrome). However, it showed blank if i have a native app which use location.href=url

code for web app

htmlview1.innerhtml="<iframe src='test.pdf' width=300 height=300></iframe>'

code for native app


Any idea?

Yes. You’re probably running into CORS errors.

Connect a remote debugger to your app - you should see error messages when it tries to access the file. You have to give your app permission to access the file.

from remote debugger, nothing about CORS error.
what to suggest to have the file access permission setting?

ps: this is workable if is as web app. No need CORS setting if web app?


What you’re doing almost certainly requires an entry in your content-security-policy (CSP). I’m surprised there isn’t an error on the console.

Here’s a useful site.