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

Preserve the last text size for a pdf session

This commit is contained in:
Vincent LAURENT 2023-07-22 01:18:40 +02:00
parent c375b43b14
commit c4c2183132

View File

@ -18,6 +18,7 @@ var currentCursor = null;
var signaturePad = null; var signaturePad = null;
var nblayers = null; var nblayers = null;
var hasModifications = false; var hasModifications = false;
var currentTextScale = 1;
var loadPDF = async function(pdfBlob, filename) { var loadPDF = async function(pdfBlob, filename) {
const pdfjsLib = window['pdfjs-dist/build/pdf']; const pdfjsLib = window['pdfjs-dist/build/pdf'];
@ -136,6 +137,10 @@ var loadPDF = async function(pdfBlob, filename) {
} }
}); });
canvasEdition.on('object:scaled', function(event) { canvasEdition.on('object:scaled', function(event) {
if (event.target instanceof fabric.IText) {
currentTextScale = event.target.scaleX;
return;
}
var item = getSvgItem(event.target.svgOrigin); var item = getSvgItem(event.target.svgOrigin);
if(!item) { if(!item) {
return; return;
@ -533,6 +538,8 @@ var createAndAddSvgInCanvas = function(canvas, item, x, y, height = null) {
addObjectInCanvas(canvas, textbox).setActiveObject(textbox); addObjectInCanvas(canvas, textbox).setActiveObject(textbox);
textbox.keysMap[13] = "exitEditing"; textbox.keysMap[13] = "exitEditing";
textbox.lockScalingFlip = true; textbox.lockScalingFlip = true;
textbox.scaleX = currentTextScale;
textbox.scaleY = currentTextScale;
textbox.enterEditing(); textbox.enterEditing();
textbox.selectAll(); textbox.selectAll();