Pdf.js: SecurityError: Permission denied to access property "print" on cross-origin object

Created on 30 Mar 2018  ·  5Comments  ·  Source: mozilla/pdf.js

Attach (recommended) or Link to PDF file here:

Configuration:

  • Web browser and its version: firefox 59.0.2 (64 位)
  • Operating system and its version: windows 10 x64
  • PDF.js version:
  • Is a browser extension:

Steps to reproduce the problem:

  1. SecurityError: Permission denied to access property "print" on cross-origin object
    2.

What is the expected behavior? (add screenshot)

What went wrong? (add screenshot)

Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):

Most helpful comment

So far, no solution has been proposed

All 5 comments

Closing since this looks like a duplicate of #5397, which has more debugging information.

So far, no solution has been proposed

The problem is the viewer. The embedded viewer causes the cross-origin problem. Try creating your own viewer. That will solve the problem. e.g. from here: https://pspdfkit.com/blog/2019/implement-pdf-viewer-pdf-js/

Or if you need a full featured viewer, you can use the Mozilla one from here: http://mozilla.github.io/pdf.js/web/viewer.html (for this one you will need to download the latest pdf.js and pdf.worker.js implementation). I just did that for a project at work, and it works like a charm.

@vaspervnp Why does the embedded viewer cause the problem? What part of the viewer is making the window think that it's url is on a different domain?

@worthy7 It loads the viewer from a local resource namespace. The browser thinks that is a different domain, because it actually is.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sujit-baniya picture sujit-baniya  ·  3Comments

azetutu picture azetutu  ·  4Comments

PeterNerlich picture PeterNerlich  ·  3Comments

aaronshaf picture aaronshaf  ·  3Comments

THausherr picture THausherr  ·  3Comments