1
0
mirror of https://github.com/24eme/signaturepdf.git synced 2023-08-25 09:33:08 +02:00

Redimensionnement des objets lors du redimensionnement du canvas fabric

This commit is contained in:
Vincent LAURENT 2021-10-10 01:41:53 +02:00
parent 3c0633f1f4
commit df76224575

View File

@ -423,12 +423,26 @@ loadingTask.promise.then(function(pdf) {
viewport = page.getViewport({ scale: scale }); viewport = page.getViewport({ scale: scale });
} }
var canvasPDF = document.getElementById('canvas-pdf-' + pageIndex); var canvasPDF = document.getElementById('canvas-pdf-' + pageIndex);
var canvasEditionHTML = document.getElementById('canvas-edition-' + pageIndex);
var context = canvasPDF.getContext('2d'); var context = canvasPDF.getContext('2d');
canvasPDF.height = viewport.height; canvasPDF.height = viewport.height;
canvasPDF.width = viewport.width; canvasPDF.width = viewport.width;
/*canvasEditionHTML.height = canvasPDF.height; canvasEdition = canvasEditions[pageIndex];
canvasEditionHTML.width = canvasPDF.width;*/
var scaleMultiplier = canvasPDF.width / canvasEdition.width;
var objects = canvasEdition.getObjects();
for (var i in objects) {
objects[i].scaleX = objects[i].scaleX * scaleMultiplier;
objects[i].scaleY = objects[i].scaleY * scaleMultiplier;
objects[i].left = objects[i].left * scaleMultiplier;
objects[i].top = objects[i].top * scaleMultiplier;
objects[i].setCoords();
}
canvasEdition.setWidth(canvasEdition.getWidth() * scaleMultiplier);
canvasEdition.setHeight(canvasEdition.getHeight() * scaleMultiplier);
canvasEdition.renderAll();
canvasEdition.calcOffset();
var renderContext = { var renderContext = {
canvasContext: context, canvasContext: context,
viewport: viewport, viewport: viewport,
@ -504,7 +518,6 @@ loadingTask.promise.then(function(pdf) {
input_selected.checked = false; input_selected.checked = false;
input_selected.dispatchEvent(new Event("change")); input_selected.dispatchEvent(new Event("change"));
}); });
canvasEditions.push(canvasEdition); canvasEditions.push(canvasEdition);
}); });
} }