mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-17 06:05:29 +01:00
This commit is contained in:
parent
1aaabefe05
commit
ca1f1308a5
1 changed files with 5 additions and 8 deletions
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue