Canvas-based PDF embedded in rotated SVG element does not render correctly in Chrome
See original GitHub issueAttach (recommended) or Link to PDF file here: I am using a publicly accessible PDF file (in this case, the PDF representation of the Wikipedia article on the HTML5 canvas) for the sake of demonstration because I couldn’t get Chrome to load a local PDF file via a relative URL for my minimal working example. In my real application, I tried this with a couple of different PDF files, though, and the result was always the same.
Configuration:
- Web browser and its version: Chrome 74
- Operating system and its version: Windows 10 x64
- PDF.js version: 2.2.2
- Is a browser extension: no
Steps to reproduce the problem:
- Create an HTML page.
- Insert some SVG data.
- Within that SVG data, apply a transform with a rotation.
- Within that transformed SVG fragment, add a <foreignObject> that contains a canvas.
- Use that canvas as a rendering target for PDF.js.
(From various resources associated with this project, my understanding is that the PDF-to-SVG renderer from PDF.js is not yet as mature and feature-complete as the canvas-based PDF renderer.)
Sample files: pdfjsCanvasInSvg.zip
What is the expected behavior? (add screenshot)
Firefox 66 displays test.html
as expected:
What went wrong? (add screenshot)
Chrome 74, on the other hand, displays an unexpected portion of the PDF document and does not apply the rotation:
Asking about this issue on StackOverflow has so far yielded a hint that it might be a quirk in how Chrome handles the canvas. However, if I draw something simple into the canvas myself rather than having PDF.js fill the canvas (cf. test_ok.html
), Chrome does apply the rotation also to the canvas drawing:
This makes me wonder whether Chrome is behaving weirdly due to something specific PDF.js does while using the canvas. Is this a known issue?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I tried removing the use of PDF.js entirely and just modified the
width
andheight
with some simple code. It causes the same rendering issues in Chrome. It looks to me like this is a bug in Chrome.Thank you. I would suggest to report this upstream in the Chrome bug tracker then.