From ca1f1308a5497ddcdba55cbb6c6818dbec552b0e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 10 Jan 2026 21:39:21 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/pull/16714 --- app/src/asset/anno.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/src/asset/anno.ts b/app/src/asset/anno.ts index eb382d357..f7a28e51f 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),