Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR attempts to improve the PDF resolution in the viewer, that, even if we are following the solution found in many places, it's not satisfying.
We introduced a variable called
resolution_boost
that apply a boost on how the resolution is calculated. The value goes from 2 to 10, with default to 1.The canvas of the PDF pages is built by getting the Viewport (unscaled) and calculating the scaling ratio by dividing the expected width and the actual viewport width.
When the canvas is created, we use the scaled viewport dimensions and we multiply by a ratio value due to the density of pixels of the device (given by
window.devicePixelRatio
), in the current version, this value is either 1 or 2 (retina displays).However, the quality of the PDF shown still is not optimal.
So we added a boost ratio that will be a multiplied for the calculated ratio:
this approach, gave acceptable results in our experiments. Nevertheless, we did not find any explanation and it might be used incorrectly.
Higher ratio is definitely more resource-demanding on the browser, so use carefully, and, at your own risk :-)