Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Limit pixelRatio used for output/rendering #17343

Closed
CONOVA24 opened this issue Nov 27, 2023 · 1 comment
Closed

Request: Limit pixelRatio used for output/rendering #17343

CONOVA24 opened this issue Nov 27, 2023 · 1 comment

Comments

@CONOVA24
Copy link

I previously raised this issue, but I feel it's crucial to address it.

My concern involves high-resolution scanned PDFs, typically construction blueprints, which are significantly large in size. These documents, being scanned, essentially consist of a single, expansive image. When displayed on high-resolution screens (where devicePixelRatio exceeds 1), the image's size surpasses the maximum canvas pixel limit of the browser. Given the high resolution of these PDFs, it's unnecessary for the output to maintain a PixelRatio greater than 1 to ensure good quality. Currently, attempting to load these PDFs results in failure and a warning, which I'm unable to capture or display in the browser.

Therefore, I suggest implementing a feature to adjust/limit the output scale/resolution. This adjustment would enable the browser to effectively handle PDFs containing large images, ensuring they load properly without compromising quality.

Another potential solution is to divide the image into smaller sections. However, I believe this approach might be more complex.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Nov 27, 2023

I previously raised this issue, but I feel it's crucial to address it.

Duplicate of #17170; please don't knowingly open duplicate issues!

[...] the image's size surpasses the maximum canvas pixel limit of the browser.

There's already code that will downsize huge images, please see PR #16077.
However, this functionality depends on OffscreenCanvas being available in the browser; perhaps your browser doesn't support this? https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas#browser_compatibility

Therefore, I suggest implementing a feature to adjust/limit the output scale/resolution. This adjustment would enable the browser to effectively handle PDFs containing large images, ensuring they load properly without compromising quality.

As already mentioned in #17170 (comment) that's probably less straightforward than you think, and we cannot implement options for everything that users may want (since every options adds maintenance/support burden).

Edit: There's also an existing viewer-option that sounds relevant here, see e.g.

pdf.js/web/pdf_viewer.js

Lines 118 to 120 in b7e943b

* @property {number} [maxCanvasPixels] - The maximum supported canvas size in
* total pixels, i.e. width * height. Use `-1` for no limit, or `0` for
* CSS-only zooming. The default value is 4096 * 4096 (16 mega-pixels).

Another potential solution is to divide the image into smaller sections. However, I believe this approach might be more complex.

This is already tracked in issue #6419, which was mentioned previously as well.

@Snuffleupagus Snuffleupagus closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants