Skip to content

Commit 5d47e14

Browse files
Uses pixels with pdf to css conversion
1 parent 4f97195 commit 5d47e14

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/react-pdf/src/Page/PageCanvas.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,14 @@ export default function PageCanvas(props: PageCanvasProps) {
104104
canvas.width = renderViewport.width;
105105
canvas.height = renderViewport.height;
106106

107-
canvas.style.width = `${Math.floor(viewport.width) * pdfjs.PDF_TO_CSS_UNITS}pt`;
108-
canvas.style.height = `${Math.floor(viewport.height) * pdfjs.PDF_TO_CSS_UNITS}pt`;
107+
108+
const CSS = 96.0;
109+
const PDF = 72.0;
110+
const PDF_TO_CSS_UNITS = CSS / PDF;
111+
112+
canvas.style.width = `${Math.floor(viewport.width) * PDF_TO_CSS_UNITS}px`;
113+
canvas.style.height = `${Math.floor(viewport.height) * PDF_TO_CSS_UNITS}px`;
114+
109115
canvas.style.visibility = 'hidden';
110116

111117
const renderContext: RenderParameters = {

0 commit comments

Comments
 (0)