Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix https://github.com/siyuan-note/siyuan/issues/9076

Vanessa8d66c577997c
diff --git a/app/src/asset/anno.ts b/app/src/asset/anno.ts
index 3a46426cd0..ed0c6f5cd0 100644
--- a/app/src/asset/anno.ts
+++ b/app/src/asset/anno.ts
@@ -638,7 +638,7 @@ const copyAnno = (idPath: string, fileName: string, pdf: any) => {
const getCaptureCanvas = async (pdfObj: any, pageNumber: number) => {
const pdfPage = await pdfObj.pdfDocument.getPage(pageNumber);
- const viewport = pdfPage.getViewport({scale: window.devicePixelRatio || 1});
+ const viewport = pdfPage.getViewport({scale: 2}); // 不使用 window.devicePixelRatio 否则 window 下画质不够
const canvas = document.createElement("canvas");
canvas.width = Math.floor(viewport.width);
canvas.height = Math.floor(viewport.height);
@@ -660,7 +660,7 @@ async function getRectImgData(pdfObj: any) {
const captureCanvas = await getCaptureCanvas(pdfObj, parseInt(pageElement.getAttribute("data-page-number")));
const rectStyle = (rectElement.firstElementChild as HTMLElement).style;
- const scale = (window.devicePixelRatio || 1) / pdfObj.pdfViewer.currentScale / window.pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
+ const scale = 2 / pdfObj.pdfViewer.currentScale / window.pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
const captureImageData = captureCanvas.getContext("2d").getImageData(
scale * parseFloat(rectStyle.left),
scale * parseFloat(rectStyle.top),