Skip to content

Conversation

@danxuliu
Copy link
Member

Fixes #62

The default implementation of PDFViewerApplication.download creates a blob which is then downloaded using the download manager from PDF.js. This causes a CSP error in Firefox, so in 7bcdc4f the default implementation was replaced with a window.open call with the URL of the file.

Besides through a blob, the download manager from PDF.js also supports downloading a file through its URL. Thus, in order to keep closer to the default PDF.js viewer, now the custom implementation of PDFViewerApplication.download was changed to download the file using the download manager from PDF.js.

Note that window.open does not work in Internet Explorer 11 (in this specific case, probably due to the use of iframes or something like that; it is Internet Explorer... so to be honest I did not bother digging into it :-P ), so this change also fixes the download in Internet Explorer 11, it is not just an academic change.

When testing this pull request please be aware of #82

The default implementation of "PDFViewerApplication.download" creates a
blob which is then downloaded using the download manager from PDF.js.
This causes a CSP error in Firefox, so in 7bcdc4f the default
implementation was replaced with a "window.open" call with the URL of
the file.

Besides through a blob, the download manager from PDF.js also supports
downloading a file through its URL. Thus, in order to keep closer to the
default PDF.js viewer, now the custom implementation of
"PDFViewerApplication.download" was changed to download the file using
the download manager from PDF.js.

Note that "window.open" does not work in Internet Explorer 11 (in this
specific case, probably due to the use of iframes or something like
that), so this change also fixes the download in Internet Explorer 11,
it is not just an "academic" change.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works (was also broken in Edge) 👍

@MorrisJobke MorrisJobke merged commit 112045c into master Jun 15, 2018
@MorrisJobke MorrisJobke deleted the use-download-manager-from-pdfjs-to-download-the-file branch June 15, 2018 06:25
@MorrisJobke
Copy link
Member

Please open a backport PR for stable13

@danxuliu
Copy link
Member Author

Backport is in #84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDF file could not be downloaded in IE instead there is an empty page

3 participants