mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
The download button of a page allows to download the page
This commit is contained in:
parent
b1e7f02215
commit
d842917573
@ -101,6 +101,16 @@ var loadPDF = async function(pdfBlob, filename, pdfIndex) {
|
||||
document.querySelector('#container-btn-save').classList.remove('d-none');
|
||||
}
|
||||
});
|
||||
canvasContainer.querySelector('.btn-download').addEventListener('click', function(e) {
|
||||
let container = this.parentNode;
|
||||
let pageValue = container.querySelector('.checkbox-page').value;
|
||||
let orientation = degreesToOrientation(container.querySelector('.input-rotate').value);
|
||||
if(orientation) {
|
||||
pageValue = pageValue + "-" + orientation;
|
||||
}
|
||||
document.querySelector('#input_pages').value = pageValue;
|
||||
document.querySelector('#form_pdf').submit();
|
||||
});
|
||||
canvasContainer.querySelector('.btn-rotate').addEventListener('click', function(e) {
|
||||
let inputRotate = document.querySelector('#input_rotate_'+pageIndex);
|
||||
inputRotate.value = (parseInt(inputRotate.value) + 90) % 360;
|
||||
@ -169,7 +179,18 @@ var updateListePDF = function() {
|
||||
}
|
||||
}
|
||||
|
||||
var degreesToOrientation = function(degrees) {
|
||||
if(degrees == 90) { return "east"; }
|
||||
if(degrees == 180) { return "south"; }
|
||||
if(degrees == 270) { return "west"; }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var createEventsListener = function() {
|
||||
document.getElementById('save-select').addEventListener('click', function(event) {
|
||||
document.getElementById('save').click();
|
||||
});
|
||||
document.getElementById('save').addEventListener('click', function(event) {
|
||||
let order = [];
|
||||
|
||||
@ -188,14 +209,9 @@ var createEventsListener = function() {
|
||||
if(checkbox.checked) {
|
||||
pageValue = checkbox.value;
|
||||
}
|
||||
if(pageValue && inputRotate.value == 90) {
|
||||
pageValue = pageValue + "-east";
|
||||
}
|
||||
if(pageValue && inputRotate.value == 180) {
|
||||
pageValue = pageValue + "-south";
|
||||
}
|
||||
if(pageValue && inputRotate.value == 270) {
|
||||
pageValue = pageValue + "-west";
|
||||
let orientation = degreesToOrientation(inputRotate.value);
|
||||
if(pageValue && orientation) {
|
||||
pageValue = pageValue + "-" + orientation;
|
||||
}
|
||||
if(pageValue) {
|
||||
order.push(pageValue);
|
||||
|
@ -62,7 +62,7 @@
|
||||
<input id="input_pages" type="hidden" value="" name="pages" />
|
||||
<div id="container-btn-save-select" class="d-grid gap-2 mt-2 d-none">
|
||||
<button id="btn_cancel_select" type="button" class="btn btn-link">Annuler la sélection</button>
|
||||
<button class="btn btn-outline-primary" type="submit" id="save"><i class="bi bi-download"></i> Télécharger les pages séléctionnées</button>
|
||||
<button class="btn btn-outline-primary" type="submit" id="save-select"><i class="bi bi-download"></i> Télécharger les pages séléctionnées</button>
|
||||
</div>
|
||||
<div id="container-btn-save" class="d-grid gap-2 mt-2">
|
||||
<button class="btn btn-primary" type="submit" id="save"><i class="bi bi-download"></i> Télécharger le PDF</button>
|
||||
|
Loading…
Reference in New Issue
Block a user