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:
parent
37f7973eee
commit
123f6b4510
@ -250,24 +250,36 @@ loadingTask.promise.then(function(pdf) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
canvasEdition.on('mouse:dblclick', function(event) {
|
canvasEdition.on('mouse:dblclick', function(event) {
|
||||||
|
var input_selected = document.querySelector('input[name="svg_2_add"]:checked');
|
||||||
|
|
||||||
|
if(!input_selected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x = event.pointer.x
|
x = event.pointer.x
|
||||||
y = event.pointer.y
|
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) {
|
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);
|
var svg = fabric.util.groupSVGElements(objects, options);
|
||||||
svg.scaleToHeight(100);
|
svg.scaleToHeight(100);
|
||||||
svg.top = y - (svg.getScaledHeight() / 2);
|
svg.top = y - (svg.getScaledHeight() / 2);
|
||||||
svg.left = x - (svg.getScaledWidth() / 2);
|
svg.left = x - (svg.getScaledWidth() / 2);
|
||||||
canvasEdition.add(svg).renderAll();
|
canvasEdition.add(svg).renderAll();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
/*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();
|
|
||||||
}*/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
canvasEditions.push(canvasEdition);
|
canvasEditions.push(canvasEdition);
|
||||||
|
@ -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>
|
<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">
|
<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 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">
|
<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>
|
</div>
|
||||||
<hr />
|
<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>
|
<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>
|
||||||
|
Loading…
Reference in New Issue
Block a user