zdg #78

Merged
zhengdegang merged 6 commits from zdg into main 2024-07-26 22:16:53 +08:00
1 changed files with 20 additions and 21 deletions
Showing only changes of commit 0d2fe7655f - Show all commits

View File

@ -50,8 +50,7 @@ const renderPage = async (canvasobj) => {
const pdf = await pdfjsLib.getDocument(props.pdfObj.pdfUrl).promise const pdf = await pdfjsLib.getDocument(props.pdfObj.pdfUrl).promise
// //
const page = await pdf.getPage(canvasobj.page) const page = await pdf.getPage(canvasobj.page)
const viewport = page.getViewport({ scale: 1 }) const viewport = page.getViewport({ scale: 1.28 })
const canvasElement = canvasobj.canvas const canvasElement = canvasobj.canvas
canvasElement.width = viewport.width canvasElement.width = viewport.width
canvasElement.height = viewport.height canvasElement.height = viewport.height
@ -67,34 +66,34 @@ const renderPage = async (canvasobj) => {
img.onload = () => { img.onload = () => {
// //
// pdf fabric // pdf fabric
var screenWidth = window.innerWidth/2-10; // var screenWidth = window.innerWidth/2-10;
var screenHeight = window.innerHeight; // var screenHeight = window.innerHeight;
// // //
var imgWidth = img.width; // var imgWidth = img.width;
var imgHeight = img.height; // var imgHeight = img.height;
// // //
var widthRatio = screenWidth / imgWidth; // var widthRatio = screenWidth / imgWidth;
var heightRatio = screenHeight / imgHeight; // var heightRatio = screenHeight / imgHeight;
// // //
var scaleRatio = Math.min(widthRatio, heightRatio); // var scaleRatio = Math.min(widthRatio, heightRatio);
// // //
var targetWidth = imgWidth * scaleRatio; // var targetWidth = imgWidth * scaleRatio;
var targetHeight = imgHeight * scaleRatio; // var targetHeight = imgHeight * scaleRatio;
if (props.pdfObj.numberOfPdf == 2) { if (props.pdfObj.numberOfPdf == 2) {
if (canvasobj.index == 0) { if (canvasobj.index == 0) {
fabriccanvas.value.setWidth(targetWidth) fabriccanvas.value.setWidth(img.width)
fabriccanvas.value.setHeight(targetHeight) fabriccanvas.value.setHeight(img.height)
displayData(fabriccanvas, canvsStore, canvasobj, fabric, img) displayData(fabriccanvas, canvsStore, canvasobj, fabric, img)
} else { } else {
fabriccanvas1.value.setWidth(targetWidth) fabriccanvas1.value.setWidth(img.width)
fabriccanvas1.value.setHeight(targetHeight) fabriccanvas1.value.setHeight(img.height)
displayData(fabriccanvas1, canvsStore, canvasobj, fabric, img) displayData(fabriccanvas1, canvsStore, canvasobj, fabric, img)
} }
} else { } else {
fabriccanvas.value.setWidth(targetWidth) fabriccanvas.value.setWidth(img.width)
fabriccanvas.value.setHeight(targetHeight) fabriccanvas.value.setHeight(img.height)
displayData(fabriccanvas, canvsStore, canvasobj, fabric, img) displayData(fabriccanvas, canvsStore, canvasobj, fabric, img)
} }
// console.log(imgarr.value) // console.log(imgarr.value)