mirror of
https://github.com/24eme/signaturepdf
synced 2024-05-15 20:26:36 +02:00
Signature texte
This commit is contained in:
parent
a433eefc1c
commit
42f29e832c
20
js/app.js
20
js/app.js
|
@ -71,13 +71,23 @@ loadingTask.promise.then(function(pdf) {
|
|||
if(svgImage) {
|
||||
svg2add = svgImage;
|
||||
}
|
||||
|
||||
if(document.getElementById('input-text-signature').value) {
|
||||
var textSignature = new fabric.Text(document.getElementById('input-text-signature').value, {
|
||||
fontFamily: 'Caveat'
|
||||
});
|
||||
textSignature.top = y - (textSignature.getScaledHeight() / 2);
|
||||
textSignature.left = x - (textSignature.getScaledWidth() / 2);
|
||||
canvasEdition.add(textSignature).renderAll();
|
||||
}
|
||||
|
||||
|
||||
fabric.loadSVGFromURL(svg2add, function(objects, options) {
|
||||
options.left = x;
|
||||
options.top = y;
|
||||
var obj = fabric.util.groupSVGElements(objects, options);
|
||||
console.log(obj);
|
||||
canvasEdition.add(obj).renderAll();
|
||||
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();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
12
pdf.html.php
12
pdf.html.php
|
@ -8,6 +8,9 @@
|
|||
<!-- Bootstrap CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Caveat&display=swap" rel="stylesheet">
|
||||
<title>Signature PDF</title>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -18,11 +21,12 @@
|
|||
<h5><i class="bi bi-vector-pen"></i> Signature à main lever</h5>
|
||||
<canvas id="signature-pad" class="border bg-light" width=200 height=150></canvas>
|
||||
<hr />
|
||||
<h5><i class="bi bi-fonts"></i> Signature texte</h5>
|
||||
<input id="input-text-signature" type="text" class="form-control" placeholder="Ma signature" style="font-family: 'Caveat', cursive; font-size: 24px;" />
|
||||
<hr />
|
||||
<form id="form-image-upload" action="/image2svg" method="POST" class="row g-3" enctype="multipart/form-data">
|
||||
<div class="col-12">
|
||||
<h5><i class="bi bi-image"></i> Importer une image</h5>
|
||||
<input id="input-image-upload" class="form-control" name="image" type="file">
|
||||
</div>
|
||||
<h5><i class="bi bi-image"></i> Importer une image</h5>
|
||||
<input id="input-image-upload" class="form-control" name="image" type="file">
|
||||
</form>
|
||||
<hr />
|
||||
<p><small class="text-muted">Double-cliquez sur le PDF pour ajouter la signature</small></p>
|
||||
|
|
Loading…
Reference in a new issue