pdf.js: [Bug]: Adding a ` ` tag to a page containing a pdfjs viewer breaks transparancy filters in Firefox.
Attach (recommended) or Link to PDF file
https://github.com/mozilla/pdf.js/files/11229069/test.pdf
Web browser and its version
Firefox 127.0.2
Operating system and its version
Mac and Windows
PDF.js version
4.5 (master)
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
- Running local copy of pdfjs using
npx gulp server - Add
<base href="." />toviewer.html - Open test.pdf
What is the expected behavior?
The PDF should render the same regardless of <base href>
What went wrong?
When rendering a pdf in Firefox when a <base href> is defined the drop shadow is not rendered correctly.
Link to a viewer
No response
Additional context
This issue was discovered and discussed here: https://github.com/stephanrauh/ngx-extended-pdf-viewer/issues/2363
We tested accross multiple browsers, OSs, sites, and PDFs. The issue was eventually narrowed down to pdfjs v4.3-v4.5 in Firefox when the site defines a <base href>. Many SPAs require a base href to be defined. This issue was not seen in other browsers nor in pdfjs v.4.2. It was seen in Firefox regardless of OS.
Additional note: Relatively certain this issue is SVG IRI references in display_utils.js.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (2 by maintainers)
@calixteman I was thinking
!!this.#document.querySelector('head base')?.attributes.href.valueor something like that.Please see: https://github.com/mozilla/pdf.js/blob/1bdd6920ff0b443ab7893ee103d8185bcf2bb7f2/src/display/api.js#L139-L141
No, that’s not appropriate since (as documented) it has a completely different purpose.
No, that parameter is user defined and can be any valid URL.
The smallest patch I could imagine, assuming that we actually want to attempt to fix this, would be something along these lines (with the functionality limited to GENERIC builds): https://github.com/mozilla/pdf.js/compare/master...Snuffleupagus:pdf.js:DOMFilterFactory-baseUrl
That sounds essentially like the following
getDocumentparameter: https://github.com/mozilla/pdf.js/blob/1bdd6920ff0b443ab7893ee103d8185bcf2bb7f2/src/display/api.js#L194-L196