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

Possibilité d'ajouté une zone de texte dans le pdf

This commit is contained in:
Vincent LAURENT 2021-09-28 21:32:35 +02:00
parent 37f7973eee
commit 123f6b4510
2 changed files with 33 additions and 17 deletions

View File

@ -250,24 +250,36 @@ loadingTask.promise.then(function(pdf) {
});
canvasEdition.on('mouse:dblclick', function(event) {
x = event.pointer.x
y = event.pointer.y
if(document.querySelector('input[name="svg_2_add"]:checked')) {
fabric.loadSVGFromURL(document.querySelector('input[name="svg_2_add"]:checked').value, function(objects, options) {
var svg = fabric.util.groupSVGElements(objects, options);
svg.scaleToHeight(100);
svg.top = y - (svg.getScaledHeight() / 2);
svg.left = x - (svg.getScaledWidth() / 2);
canvasEdition.add(svg).renderAll();
});
var input_selected = document.querySelector('input[name="svg_2_add"]:checked');
if(!input_selected) {
return;
}
/*if(document.getElementById('radio_signature_text_classic').checked) {
var textSignature = new fabric.Text(document.getElementById('input-signature-text-classic').value, { fontSize: 16 });
textSignature.top = y - (textSignature.getScaledHeight() / 2);
textSignature.left = x - (textSignature.getScaledWidth() / 2);
canvasEdition.add(textSignature).renderAll();
}*/
x = event.pointer.x
y = event.pointer.y
if(input_selected.value == 'text') {
var textbox = new fabric.Textbox('Texte à modifier', {
left: x - 10,
top: y - 10,
width: 300,
fontSize: 20
});
canvasEdition.add(textbox).setActiveObject(textbox);
textbox.enterEditing();
textbox.selectAll();
return;
}
fabric.loadSVGFromURL(input_selected.value, function(objects, options) {
var svg = fabric.util.groupSVGElements(objects, options);
svg.scaleToHeight(100);
svg.top = y - (svg.getScaledHeight() / 2);
svg.left = x - (svg.getScaledWidth() / 2);
canvasEdition.add(svg).renderAll();
});
});
canvasEditions.push(canvasEdition);

View File

@ -23,8 +23,12 @@
<div id="container-pages" class="col-lg-10 col-md-9 col-sm-8 col-xs-6 bg-light text-center"></div>
<aside class="col-lg-2 col-md-3 col-sm-4 col-xs-6 mt-2 position-fixed end-0 bg-white">
<div id="svg_list" class="d-grid gap-2"></div>
<div class="d-grid gap-2 mt-2">
<button type="button" class="btn btn-lg btn-light" data-bs-toggle="modal" data-bs-target="#modalAddSvg"><i class="bi bi-plus-circle"></i> Ajouter un élément</button>
</div>
<div class="d-grid gap-2 mt-3">
<button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#modalAddSvg"><i class="bi bi-plus-circle"></i> Ajouter un élément</button>
<input type="radio" class="btn-check" id="radio_svg_text" name="svg_2_add" autocomplete="off" value="text">
<label class="btn btn-lg btn-outline-secondary text-black text-start" for="radio_svg_text"><i class="bi bi-textarea-t"></i> Ajouter du texte</label>
</div>
<hr />
<p><small class="text-muted"><i class="bi bi-hand-index"></i><i class="bi bi-hand-index"></i> <i class="bi bi-plus-circle-fill"></i> Double-cliquez sur le PDF pour ajouter l'élément sélectionné</small></p>