pdf.js render resolves silently on oversized pages, leaving a transparent canvas
A developer found that pdf.js render() can resolve successfully on a very large PDF page while the canvas it draws to is actually empty. Testing on desktop Chromium with pdfjs-dist 4.4.168 showed the failure begins once the canvas exceeds about 268 million pixels in area, with no thrown error or console message. Reading back pixels or calling toDataURL() revealed the blank output, since a canvas over the browser's limit still returns a valid context. The author suggests a post-render alpha check on a single pixel to catch the failure, while noting it only fits pages with a default white background. The tests covered only one blank vector page and one browser on one machine, so results may differ elsewhere.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in