Skip to content

Commit

Permalink
🐛 fix #9076
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Aug 31, 2023
1 parent 008e5e6 commit 8d66c57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/src/asset/anno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
Expand Down

0 comments on commit 8d66c57

Please sign in to comment.