mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-09 18:03:15 +01:00
fix (pdf): pdfjs on retina screen
whenever using a retina typed screen, the PDF rendering would appear as blurry. With this trick we largely improve rendering on those type of screen
This commit is contained in:
parent
fed2b0f409
commit
0936c78779
1 changed files with 4 additions and 1 deletions
|
|
@ -63,6 +63,7 @@ async function ctrlPDFJs(render) {
|
|||
for (let i=0; i<pdf.numPages; i++) {
|
||||
const page = await pdf.getPage(i + 1);
|
||||
const marginLeftRight = (document.body.clientWidth > 600 ? 50 : 15);
|
||||
const ratio = window.devicePixelRatio || 1;
|
||||
const viewport = page.getViewport({
|
||||
scale: Math.min(
|
||||
Math.max(
|
||||
|
|
@ -70,11 +71,13 @@ async function ctrlPDFJs(render) {
|
|||
0,
|
||||
),
|
||||
800,
|
||||
) / page.getViewport({ scale: 1 }).width,
|
||||
) / page.getViewport({ scale: 1 / ratio }).width,
|
||||
});
|
||||
const $canvas = document.createElement("canvas");
|
||||
$canvas.height = viewport.height;
|
||||
$canvas.width = viewport.width;
|
||||
$canvas.style.width = Math.floor(viewport.width / ratio) + "px";
|
||||
$canvas.style.height = Math.floor(viewport.height / ratio) + "px";
|
||||
$container.appendChild($canvas);
|
||||
if (window.env === "test") $canvas.getContext = () => null;
|
||||
await page.render({
|
||||
|
|
|
|||
Loading…
Reference in a new issue