Skip to content

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

:art: https://github.com/siyuan-note/siyuan/pull/16714

Vanessaca1f1308a549
diff --git a/app/src/asset/anno.ts b/app/src/asset/anno.ts
index eb382d357c..f7a28e51fd 100644
--- a/app/src/asset/anno.ts
+++ b/app/src/asset/anno.ts
@@ -778,9 +778,10 @@ async function getRectImgData(pdfObj: any) {
const CAPTURE_SCALE_RATIO = 1.5;
const pdfPage = await pdfObj.pdfDocument.getPage(pageNumber);
- const displayViewport = pageView.viewport.clone({rotation: 0});
- // displayViewport.scale 等于以前用的 pdfObj.pdfViewer.currentScale * window.pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
- const captureViewport = pdfPage.getViewport({scale: displayViewport.scale * CAPTURE_SCALE_RATIO, rotation: 0});
+ const captureViewport = pdfPage.getViewport({
+ scale: pdfObj.pdfViewer.currentScale * window.pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS * CAPTURE_SCALE_RATIO,
+ rotation: 0
+ });
const captureCanvas = document.createElement("canvas");
captureCanvas.width = Math.floor(captureViewport.width);
captureCanvas.height = Math.floor(captureViewport.height);
@@ -791,11 +792,7 @@ async function getRectImgData(pdfObj: any) {
viewport: captureViewport
}).promise;
- const firstChild = rectElement.firstElementChild as HTMLElement;
- if (!firstChild) {
- return;
- }
- const rectStyle = firstChild.style;
+ const rectStyle = (rectElement.firstElementChild as HTMLElement).style;
const captureImageData = captureCtx.getImageData(
CAPTURE_SCALE_RATIO * parseFloat(rectStyle.left),
CAPTURE_SCALE_RATIO * parseFloat(rectStyle.top),