From d07788607cfb7807e2f183b8cafee48b4fddf160 Mon Sep 17 00:00:00 2001 From: asrient <44570278+asrient@users.noreply.github.com> Date: Mon, 12 Sep 2022 20:37:39 +0530 Subject: [PATCH] Desktop: Fix pdf text blurry (#6843) --- .eslintignore | 3 +++ .gitignore | 3 +++ packages/pdf-viewer/Page.tsx | 4 ++++ packages/pdf-viewer/PdfDocument.ts | 4 +--- packages/pdf-viewer/common.css | 11 +++++++++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.eslintignore b/.eslintignore index 14b37a4fa..66c604018 100644 --- a/.eslintignore +++ b/.eslintignore @@ -993,6 +993,9 @@ packages/app-mobile/components/screens/UpgradeSyncTargetScreen.js.map packages/app-mobile/components/screens/encryption-config.d.ts packages/app-mobile/components/screens/encryption-config.js packages/app-mobile/components/screens/encryption-config.js.map +packages/app-mobile/components/searchNotes.d.ts +packages/app-mobile/components/searchNotes.js +packages/app-mobile/components/searchNotes.js.map packages/app-mobile/components/useStyles.d.ts packages/app-mobile/components/useStyles.js packages/app-mobile/components/useStyles.js.map diff --git a/.gitignore b/.gitignore index 93c0e5150..abbe8d75f 100644 --- a/.gitignore +++ b/.gitignore @@ -981,6 +981,9 @@ packages/app-mobile/components/screens/UpgradeSyncTargetScreen.js.map packages/app-mobile/components/screens/encryption-config.d.ts packages/app-mobile/components/screens/encryption-config.js packages/app-mobile/components/screens/encryption-config.js.map +packages/app-mobile/components/searchNotes.d.ts +packages/app-mobile/components/searchNotes.js +packages/app-mobile/components/searchNotes.js.map packages/app-mobile/components/useStyles.d.ts packages/app-mobile/components/useStyles.js packages/app-mobile/components/useStyles.js.map diff --git a/packages/pdf-viewer/Page.tsx b/packages/pdf-viewer/Page.tsx index a75c34b70..6395dceea 100644 --- a/packages/pdf-viewer/Page.tsx +++ b/packages/pdf-viewer/Page.tsx @@ -74,6 +74,10 @@ export default function Page(props: PageProps) { const renderPage = async () => { try { + if (canvasRef.current) { + canvasRef.current.style.height = '100%'; + canvasRef.current.style.width = '100%'; + } const renderRequest: RenderRequest = { pageNo: props.pageNo, scaledSize: props.scaledSize, diff --git a/packages/pdf-viewer/PdfDocument.ts b/packages/pdf-viewer/PdfDocument.ts index 74728d5d8..d49ee5f8e 100644 --- a/packages/pdf-viewer/PdfDocument.ts +++ b/packages/pdf-viewer/PdfDocument.ts @@ -90,6 +90,7 @@ export default class PdfDocument { checkCancelled(); const canvas = this.document.createElement('canvas'); + canvas.classList.add('page-canvas'); const viewport = page.getViewport({ scale: scaledSize.scale || 1.0 }); canvas.width = viewport.width; canvas.height = viewport.height; @@ -124,9 +125,6 @@ export default class PdfDocument { textLayerDiv.appendChild(textFragment); } - canvas.style.height = '100%'; - canvas.style.width = '100%'; - return { canvas, textLayerDiv }; }; diff --git a/packages/pdf-viewer/common.css b/packages/pdf-viewer/common.css index cdbcbc407..84152e69f 100644 --- a/packages/pdf-viewer/common.css +++ b/packages/pdf-viewer/common.css @@ -85,3 +85,14 @@ hr { background-color: rgb(54, 54, 54); } +.page-canvas { + position: absolute; + top: 0px; + left: 0px; +} + +.textLayer { + position: absolute; + top: 0px; + left: 0px; +} \ No newline at end of file