zdg #72

Merged
zhangxuelin merged 21 commits from zdg into main 2024-07-26 14:39:20 +08:00
1 changed files with 22 additions and 7 deletions
Showing only changes of commit af6236a751 - Show all commits

View File

@ -1,6 +1,6 @@
<template>
<div class="canvasitem">
<div class="pdfAdnFabric">
<div class="pdfAdnFabric" id="pdfAdnFabric">
<canvas id="pdf-fabric"></canvas>
<canvas id="pdf-fabric1" v-if="props.pdfObj.numberOfPdf == 2"></canvas>
</div>
@ -67,19 +67,34 @@ const renderPage = async (canvasobj) => {
img.onload = () => {
//
// pdf fabric
var screenWidth = window.innerWidth/2-10;
var screenHeight = window.innerHeight;
//
var imgWidth = img.width;
var imgHeight = img.height;
//
var widthRatio = screenWidth / imgWidth;
var heightRatio = screenHeight / imgHeight;
//
var scaleRatio = Math.min(widthRatio, heightRatio);
//
var targetWidth = imgWidth * scaleRatio;
var targetHeight = imgHeight * scaleRatio;
if (props.pdfObj.numberOfPdf == 2) {
if (canvasobj.index == 0) {
fabriccanvas.value.setWidth(img.width)
fabriccanvas.value.setHeight(img.height)
fabriccanvas.value.setWidth(targetWidth)
fabriccanvas.value.setHeight(targetHeight)
displayData(fabriccanvas, canvsStore, canvasobj, fabric, img)
} else {
fabriccanvas1.value.setWidth(img.width)
fabriccanvas1.value.setHeight(img.height)
fabriccanvas1.value.setWidth(targetWidth)
fabriccanvas1.value.setHeight(targetHeight)
displayData(fabriccanvas1, canvsStore, canvasobj, fabric, img)
}
} else {
fabriccanvas.value.setWidth(img.width)
fabriccanvas.value.setHeight(img.height)
fabriccanvas.value.setWidth(targetWidth)
fabriccanvas.value.setHeight(targetHeight)
displayData(fabriccanvas, canvsStore, canvasobj, fabric, img)
}
// console.log(imgarr.value)