Compare commits

...

23 Commits

Author SHA1 Message Date
Vincent LAURENT c4c2183132 Preserve the last text size for a pdf session 2023-07-22 01:18:40 +02:00
Gabriel Poma c375b43b14 Modal to inform that changes will be lost if the page is reloaded or closed 2023-07-19 14:34:41 +02:00
Vincent LAURENT 06bac144dd Bug js all cases was not planned 2023-07-18 10:36:38 +02:00
Vincent LAURENT d5f4eca0ff Button to display help point 2023-07-18 10:28:00 +02:00
Vincent LAURENT f4bab4ac5f Help message for signing a pdf with several people for the first time, because the interface could suggest that creating the signature is enough. 2023-07-18 01:57:22 +02:00
Vincent LAURENT 26aac0af94 Merge branch 'master' of github.com:24eme/signaturepdf 2023-05-20 02:08:15 +02:00
Vincent LAURENT f9c413d85a Retrieving the current commit number to display it in the footer of each page 2023-05-20 02:05:24 +02:00
Gabriel 00bf081319
Merge pull request #60 from kosssi/master 2023-05-15 14:35:25 +02:00
Gabriel 1023ebd347
Merge pull request #59 from xgaia/fix/docker 2023-05-12 16:36:10 +02:00
Simon C 5f703890ac feat: Update php version on Docker image 2023-05-12 16:01:32 +02:00
xgaia 37a678e9db chore: fix owner of the data dir 2023-05-12 12:22:58 +02:00
Vincent LAURENT 357bffc55f organization: The first upload field allows you to choose several files 2023-05-04 00:45:20 +02:00
Vincent LAURENT fee27a0311 Force js update 2023-05-03 01:49:14 +02:00
Étienne Deparis a1509a554f Message to inform that in private browsing mode (on firefox) the application does not work because opening the cache is impossible 2023-05-03 01:45:37 +02:00
Vincent LAURENT 30e7ffef89 metadata: the variable maxSize was not defined 2023-05-03 01:10:56 +02:00
Vincent LAURENT ada82de930 Force js reload to activate revert commit "prompt rechargement de la
page"
2023-05-03 01:03:46 +02:00
Vincent LAURENT 4646ad35a7 The true value of the PDF_DEMO_LINK option was not working 2023-05-03 01:00:41 +02:00
Vincent LAURENT c19f1af646
metadata: adding pdf-lib dépendance in documentation 2023-05-02 23:54:01 +02:00
Vincent LAURENT d6b6b43ac2 Merge pull request #55 from xgaia/fix/dockerfile
Fix/dockerfile
2023-05-02 23:46:23 +02:00
xgaia 7d4ae2907f style: prettier on README 2023-05-02 23:46:12 +02:00
Gabriel Poma 96b21fb850 Merge branch 'master' of github.com:24eme/signaturepdf 2023-05-02 12:32:09 +02:00
Gabriel Poma 5925d4e4c6 Revert "prompt rechargement de la page"
This reverts commit 818f08d24c.
2023-05-02 12:18:57 +02:00
xgaia c119d8d1cd chore(docker): fix dockerbuild permission issue 2023-04-21 12:32:35 +02:00
11 changed files with 160 additions and 90 deletions

View File

@ -1,10 +1,10 @@
FROM php:7.4-apache FROM php:8.2-apache
ENV SERVERNAME=localhost ENV SERVERNAME=localhost
ENV UPLOAD_MAX_FILESIZE=24M ENV UPLOAD_MAX_FILESIZE=24M
ENV POST_MAX_SIZE=24M ENV POST_MAX_SIZE=24M
ENV MAX_FILE_UPLOADS=201 ENV MAX_FILE_UPLOADS=201
ENV PDF_STORAGE_PATH= ENV PDF_STORAGE_PATH=/data
ENV DISABLE_ORGANIZATION=false ENV DISABLE_ORGANIZATION=false
ENV PDF_DEMO_LINK=true ENV PDF_DEMO_LINK=true
@ -14,15 +14,11 @@ RUN apt update && \
COPY . /usr/local/signaturepdf COPY . /usr/local/signaturepdf
RUN chown -R www-data:www-data /usr/local/signaturepdf && chmod 750 -R /usr/local/signaturepdf && \ RUN envsubst < /usr/local/signaturepdf/config/php.ini > /usr/local/etc/php/conf.d/uploads.ini && \
chmod 775 -R /usr/local/signaturepdf/entrypoint.sh && \
envsubst < /usr/local/signaturepdf/config/php.ini > /usr/local/etc/php/conf.d/uploads.ini && \
envsubst < /usr/local/signaturepdf/config/apache.conf > /etc/apache2/sites-available/signaturepdf.conf && \ envsubst < /usr/local/signaturepdf/config/apache.conf > /etc/apache2/sites-available/signaturepdf.conf && \
envsubst < /usr/local/signaturepdf/config/config.ini.tpl > /usr/local/signaturepdf/config/config.ini && \ envsubst < /usr/local/signaturepdf/config/config.ini.tpl > /usr/local/signaturepdf/config/config.ini && \
a2enmod rewrite && a2ensite signaturepdf a2enmod rewrite && a2ensite signaturepdf
WORKDIR /usr/local/signaturepdf WORKDIR /usr/local/signaturepdf
USER www-data
CMD /usr/local/signaturepdf/entrypoint.sh CMD /usr/local/signaturepdf/entrypoint.sh

View File

@ -11,7 +11,7 @@ Liste des instances permettant d'utiliser ce logiciel :
- [pdf.hostux.net](https://pdf.hostux.net) - [pdf.hostux.net](https://pdf.hostux.net)
- [pdf.nebulae.co](https://pdf.nebulae.co) - [pdf.nebulae.co](https://pdf.nebulae.co)
*N'hésitez pas à rajouter la votre via une issue ou une pull request* _N'hésitez pas à rajouter la votre via une issue ou une pull request_
## License ## License
@ -23,7 +23,7 @@ Logiciel libre sous license AGPL V3
Dépendances : Dépendances :
- php >= 5.6 - php >= 5.6
- rsvg-convert - rsvg-convert
- pdftk - pdftk
- imagemagick - imagemagick
@ -75,13 +75,13 @@ DocumentRoot /path/to/signaturepdf/public
```bash ```bash
docker build -t signaturepdf . docker build -t signaturepdf .
```` ```
#### Lancement d'un conteneur #### Lancement d'un conteneur
```bash ```bash
docker run -d --name=signaturepdf -p 8080:80 signaturepdf docker run -d --name=signaturepdf -p 8080:80 signaturepdf
```` ```
[localhost:8080](http://localhost:8080) [localhost:8080](http://localhost:8080)
@ -89,15 +89,15 @@ docker run -d --name=signaturepdf -p 8080:80 signaturepdf
Les variables suivantes permettent de configurer le déployement : Les variables suivantes permettent de configurer le déployement :
|Variable|description|exemple|defaut| | Variable | description | exemple | defaut |
|-----|-----|-----|-----| | ---------------------- | ------------------------------------------------------------------ | -------------------------------- | --------- |
|`SERVERNAME`|url de déploiement|`pdf.24eme.fr`|localhost| | `SERVERNAME` | url de déploiement | `pdf.24eme.fr` | localhost |
|`UPLOAD_MAX_FILESIZE`|Taille maximum du fichier PDF à signer|48M|24M| | `UPLOAD_MAX_FILESIZE` | Taille maximum du fichier PDF à signer | 48M | 24M |
|`POST_MAX_SIZE`|Taille maximum du fichier PDF à signer|48M|24M| | `POST_MAX_SIZE` | Taille maximum du fichier PDF à signer | 48M | 24M |
|`MAX_FILE_UPLOADS`|Nombre de pages maximum du PDF, ici 200 pages + le PDF d'origine|401|201| | `MAX_FILE_UPLOADS` | Nombre de pages maximum du PDF, ici 200 pages + le PDF d'origine | 401 | 201 |
|`PDF_STORAGE_PATH`|chemin vers lequel les fichiers pdf uploadés pourront être stockés|/data|| | `PDF_STORAGE_PATH` | chemin vers lequel les fichiers pdf uploadés pourront être stockés | /data | /data |
|`DISABLE_ORGANIZATION`|Desactiver la route Organiser|true|false| | `DISABLE_ORGANIZATION` | Desactiver la route Organiser | true | false |
|`PDF_DEMO_LINK`|Afficher, retirer ou changer le lien de PDF de démo|false, `link` or `relative path`|true| | `PDF_DEMO_LINK` | Afficher, retirer ou changer le lien de PDF de démo | false, `link` or `relative path` | true |
```bash ```bash
docker run -d --name=signaturepdf -p 8080:80 -e SERVERNAME=pdf.example.org -e UPLOAD_MAX_FILESIZE=48M -e POST_MAX_SIZE=48M -e MAX_FILE_UPLOADS=401 -e PDF_STORAGE_PATH=/data signaturepdf docker run -d --name=signaturepdf -p 8080:80 -e SERVERNAME=pdf.example.org -e UPLOAD_MAX_FILESIZE=48M -e POST_MAX_SIZE=48M -e MAX_FILE_UPLOADS=401 -e PDF_STORAGE_PATH=/data signaturepdf
@ -109,6 +109,7 @@ Voici un script permettant d'installer la solution sous Linux Alpine (testé en
Pensez à éditer la variable "domain" en début de script pour correspondre à l'URL avec laquelle elle sera appelée. Pensez à éditer la variable "domain" en début de script pour correspondre à l'URL avec laquelle elle sera appelée.
Les composants principaux sont : Les composants principaux sont :
- php 8 + php-fpm - php 8 + php-fpm
- Nginx - Nginx
- pdftk (installation "manuelle" nécessitant openjdk8) - pdftk (installation "manuelle" nécessitant openjdk8)
@ -117,6 +118,7 @@ Les composants principaux sont :
- librsvg - librsvg
Ce que fait le script : Ce que fait le script :
- Installation des dépendances - Installation des dépendances
- Configuration de php et php-fpm - Configuration de php et php-fpm
- Configuration d'Nginx - Configuration d'Nginx
@ -128,7 +130,7 @@ Ce que fait le script :
domain='sign.example.com' domain='sign.example.com'
apk update apk update
apk add bash nginx git php8 php8-fpm php8-session php8-gd php8-fileinfo openjdk8 imagemagick potrace librsvg apk add bash nginx git php8 php8-fpm php8-session php8-gd php8-fileinfo openjdk8 imagemagick potrace librsvg
cd /tmp cd /tmp
@ -164,7 +166,7 @@ server {
server_name ${domain}; server_name ${domain};
client_max_body_size 0; client_max_body_size 0;
root /var/www/signaturepdf/public/; root /var/www/signaturepdf/public/;
index index.php index.html; index index.php index.html;
@ -185,7 +187,7 @@ server {
fastcgi_buffers 128 128k; fastcgi_buffers 128 128k;
fastcgi_param PATH_INFO \$fastcgi_path_info; fastcgi_param PATH_INFO \$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000; fastcgi_pass 127.0.0.1:9000;
} }
@ -223,11 +225,13 @@ cp config/config.ini{.example,}
``` ```
Dans ce fichier `config/config.ini`, il suffit ce configurer la variable `PDF_STORAGE_PATH` avec le chemin vers lequel les fichiers pdf uploadés pourront être stockés : Dans ce fichier `config/config.ini`, il suffit ce configurer la variable `PDF_STORAGE_PATH` avec le chemin vers lequel les fichiers pdf uploadés pourront être stockés :
``` ```
PDF_STORAGE_PATH=/path/to/folder PDF_STORAGE_PATH=/path/to/folder
``` ```
Créer ce dossier : Créer ce dossier :
``` ```
mkdir /path/to/folder mkdir /path/to/folder
``` ```
@ -235,6 +239,7 @@ mkdir /path/to/folder
Le serveur web devra avoir les droits en écriture sur ce dossier. Le serveur web devra avoir les droits en écriture sur ce dossier.
Par exemple pour apache : Par exemple pour apache :
``` ```
chown www-data /path/to/folder/to/store/pdf chown www-data /path/to/folder/to/store/pdf
``` ```
@ -296,6 +301,7 @@ DEBUG=1 make test
- **OpenType.js** outils de transformation d'un texte et sa police en chemin : https://github.com/opentypejs/opentype.js (MIT) - **OpenType.js** outils de transformation d'un texte et sa police en chemin : https://github.com/opentypejs/opentype.js (MIT)
- **ImageMagick** ensemble d'outils de manipulation d'images : https://imagemagick.org/ (Apache-2.0) - **ImageMagick** ensemble d'outils de manipulation d'images : https://imagemagick.org/ (Apache-2.0)
- **Caveat** police de caractères style écriture à la main : https://github.com/googlefonts/caveat (OFL-1.1) - **Caveat** police de caractères style écriture à la main : https://github.com/googlefonts/caveat (OFL-1.1)
- **PDF-LIB** librairie js permettant de manipuler un PDF qui est utilisé pour écrire dans les métadonnées : https://pdf-lib.js.org/ (MIT)
Pour les tests : Pour les tests :
@ -313,6 +319,3 @@ Pour les tests :
Logilab a apporté une contribution financière de 1 365 € TTC à la société 24ème pour développer le mode multi signature. Logilab a apporté une contribution financière de 1 365 € TTC à la société 24ème pour développer le mode multi signature.
Le développement du logiciel a principalement été réalisé sur le temps de travail de salariés du 24ème. Le développement du logiciel a principalement été réalisé sur le temps de travail de salariés du 24ème.

24
app.php
View File

@ -10,13 +10,15 @@ $f3->set('XFRAME', null); // Allow use in an iframe
$f3->set('ROOT', __DIR__); $f3->set('ROOT', __DIR__);
$f3->set('UI', $f3->get('ROOT')."/templates/"); $f3->set('UI', $f3->get('ROOT')."/templates/");
$f3->set('UPLOADS', sys_get_temp_dir()."/"); $f3->set('UPLOADS', sys_get_temp_dir()."/");
$f3->set('COMMIT', getCommit());
$f3->config(__DIR__.'/config/config.ini'); $f3->config(__DIR__.'/config/config.ini');
if($f3->get('PDF_STORAGE_PATH') && !preg_match('|/$|', $f3->get('PDF_STORAGE_PATH'))) { if($f3->get('PDF_STORAGE_PATH') && !preg_match('|/$|', $f3->get('PDF_STORAGE_PATH'))) {
$f3->set('PDF_STORAGE_PATH', $f3->get('PDF_STORAGE_PATH').'/'); $f3->set('PDF_STORAGE_PATH', $f3->get('PDF_STORAGE_PATH').'/');
} }
if(!$f3->get('PDF_DEMO_LINK') && $f3->get('PDF_DEMO_LINK') !== false) { if($f3->get('PDF_DEMO_LINK') === null || $f3->get('PDF_DEMO_LINK') === true) {
$f3->set('PDF_DEMO_LINK', 'https://raw.githubusercontent.com/24eme/signaturepdf/master/tests/files/document.pdf'); $f3->set('PDF_DEMO_LINK', 'https://raw.githubusercontent.com/24eme/signaturepdf/master/tests/files/document.pdf');
} }
@ -359,6 +361,26 @@ $f3->route('GET /metadata',
} }
); );
function getCommit() {
if(!file_exists(__DIR__.'/.git/HEAD')) {
return null;
}
$head = str_replace(["ref: ", "\n"], "", file_get_contents(__DIR__.'/.git/HEAD'));
$commit = null;
if(strpos($head, "refs/") !== 0) {
$commit = $head;
}
if(file_exists(__DIR__.'/.git/'.$head)) {
$commit = str_replace("\n", "", file_get_contents(__DIR__.'/.git/'.$head));
}
return substr($commit, 0, 7);
}
function convertPHPSizeToBytes($sSize) function convertPHPSizeToBytes($sSize)
{ {
$sSuffix = strtoupper(substr($sSize, -1)); $sSuffix = strtoupper(substr($sSize, -1));

View File

@ -7,7 +7,7 @@ PDF_STORAGE_PATH=/path/to/folder
; Disable organization tab and routes ; Disable organization tab and routes
;DISABLE_ORGANIZATION=false ;DISABLE_ORGANIZATION=false
; Manage demo link pdf : true (by default, show), false (hide), or custom link ; Manage demo link pdf : true (by default, show with default link), false (hide), or custom link
;PDF_DEMO_LINK=true ;PDF_DEMO_LINK=true
; Metadata default fields ; Metadata default fields

7
entrypoint.sh Normal file → Executable file
View File

@ -1,17 +1,12 @@
#! /bin/bash #! /bin/bash
envsubst < /usr/local/signaturepdf/config/apache.conf > /etc/apache2/sites-available/signaturepdf.conf envsubst < /usr/local/signaturepdf/config/apache.conf > /etc/apache2/sites-available/signaturepdf.conf
envsubst < /usr/local/signaturepdf/config/php.ini > /usr/local/etc/php/conf.d/uploads.ini envsubst < /usr/local/signaturepdf/config/php.ini > /usr/local/etc/php/conf.d/uploads.ini
envsubst < /usr/local/signaturepdf/config/config.ini.tpl > /usr/local/signaturepdf/config/config.ini envsubst < /usr/local/signaturepdf/config/config.ini.tpl > /usr/local/signaturepdf/config/config.ini
chown -R www-data:www-data /usr/local/signaturepdf && chmod 750 -R /usr/local/signaturepdf
if [[ ! -z $PDF_STORAGE_PATH ]] ; then if [[ ! -z $PDF_STORAGE_PATH ]] ; then
mkdir -p $PDF_STORAGE_PATH mkdir -p $PDF_STORAGE_PATH
chown -R www-data:www-data $PDF_STORAGE_PATH chown www-data:www-data $PDF_STORAGE_PATH
chmod 750 -R $PDF_STORAGE_PATH
fi fi
apache2-foreground apache2-foreground

View File

@ -246,7 +246,14 @@ var pageUpload = async function() {
document.getElementById('page-upload').classList.remove('d-none'); document.getElementById('page-upload').classList.remove('d-none');
document.getElementById('page-metadata').classList.add('d-none'); document.getElementById('page-metadata').classList.add('d-none');
document.getElementById('input_pdf_upload').focus(); document.getElementById('input_pdf_upload').focus();
const cache = await caches.open('pdf'); let cache;
try {
cache = await caches.open('pdf');
} catch (e) {
console.error(e)
alert("Erreur d'accès au cache. Cette application ne fonctionne pas en mode de navigation privée");
return;
}
document.getElementById('input_pdf_upload').addEventListener('change', async function(event) { document.getElementById('input_pdf_upload').addEventListener('change', async function(event) {
let filename = document.getElementById('input_pdf_upload').files[0].name; let filename = document.getElementById('input_pdf_upload').files[0].name;
let response = new Response(document.getElementById('input_pdf_upload').files[0], { "status" : 200, "statusText" : "OK" }); let response = new Response(document.getElementById('input_pdf_upload').files[0], { "status" : 200, "statusText" : "OK" });

View File

@ -556,6 +556,24 @@ var degreesToOrientation = function(degrees) {
return null; return null;
} }
var uploadAndLoadPDF = async function(input_upload) {
const cache = await caches.open('pdf');
for (let i = 0; i < input_upload.files.length; i++) {
if(input_upload.files[i].size > maxSize) {
alert("Le PDF ne doit pas dépasser " + Math.round(maxSize/1024/1024) + " Mo");
break;
}
let filename = input_upload.files[i].name;
let response = new Response(input_upload.files[i], { "status" : 200, "statusText" : "OK" });
let urlPdf = '/pdf/'+filename;
await cache.put(urlPdf, response);
let pdfBlob = await getPDFBlobFromCache(urlPdf);
nbPDF++;
await loadPDF(pdfBlob, filename, nbPDF);
}
}
var createEventsListener = function() { var createEventsListener = function() {
document.getElementById('save-select_mobile').addEventListener('click', function(event) { document.getElementById('save-select_mobile').addEventListener('click', function(event) {
document.getElementById('save').click(); document.getElementById('save').click();
@ -592,21 +610,7 @@ var createEventsListener = function() {
document.getElementById('save').click(); document.getElementById('save').click();
}); });
document.getElementById('input_pdf_upload_2').addEventListener('change', async function(event) { document.getElementById('input_pdf_upload_2').addEventListener('change', async function(event) {
for (let i = 0; i < this.files.length; i++) { await uploadAndLoadPDF(this);
if(this.files[i].size > maxSize) {
alert("Le PDF ne doit pas dépasser " + Math.round(maxSize/1024/1024) + " Mo");
break;
}
const cache = await caches.open('pdf');
let filename = this.files[i].name;
let response = new Response(this.files[i], { "status" : 200, "statusText" : "OK" });
let urlPdf = '/pdf/'+filename;
await cache.put(urlPdf, response);
let pdfBlob = await getPDFBlobFromCache(urlPdf);
nbPDF++;
await loadPDF(pdfBlob, filename, nbPDF);
}
this.value = ''; this.value = '';
}); });
document.getElementById('btn-zoom-decrease').addEventListener('click', function(event) { document.getElementById('btn-zoom-decrease').addEventListener('click', function(event) {
@ -740,41 +744,28 @@ var pageUpload = async function() {
document.getElementById('page-upload').classList.remove('d-none'); document.getElementById('page-upload').classList.remove('d-none');
document.getElementById('page-organization').classList.add('d-none'); document.getElementById('page-organization').classList.add('d-none');
document.getElementById('input_pdf_upload').focus(); document.getElementById('input_pdf_upload').focus();
const cache = await caches.open('pdf'); let cache;
try {
cache = await caches.open('pdf');
} catch (e) {
console.error(e)
alert("Erreur d'accès au cache. Cette application ne fonctionne pas en mode de navigation privée");
return;
}
document.getElementById('input_pdf_upload').addEventListener('change', async function(event) { document.getElementById('input_pdf_upload').addEventListener('change', async function(event) {
if(document.getElementById('input_pdf_upload').files[0].size > maxSize) { uploadAndLoadPDF(this);
pageOrganization(null);
alert("Le PDF ne doit pas dépasser " + Math.round(maxSize/1024/1024) + " Mo");
document.getElementById('input_pdf_upload').value = "";
return;
}
let filename = document.getElementById('input_pdf_upload').files[0].name;
let response = new Response(document.getElementById('input_pdf_upload').files[0], { "status" : 200, "statusText" : "OK" });
let urlPdf = '/pdf/'+filename;
await cache.put(urlPdf, response);
history.pushState({}, '', '/organization#'+filename);
pageOrganization(urlPdf)
}); });
} }
var pageOrganization = async function(url) { var pageOrganization = async function() {
let filename = url.replace('/pdf/', '');
document.title = filename + ' - ' + document.title;
document.querySelector('body').classList.add('bg-light'); document.querySelector('body').classList.add('bg-light');
document.getElementById('page-upload').classList.add('d-none'); document.getElementById('page-upload').classList.add('d-none');
document.getElementById('page-organization').classList.remove('d-none'); document.getElementById('page-organization').classList.remove('d-none');
menu = document.getElementById('sidebarTools'); menu = document.getElementById('sidebarTools');
menuOffcanvas = new bootstrap.Offcanvas(menu); menuOffcanvas = new bootstrap.Offcanvas(menu);
responsiveDisplay(); responsiveDisplay();
let pdfBlob = await getPDFBlobFromCache(url);
if(!pdfBlob) {
document.location = '/organization';
return;
}
createEventsListener(); createEventsListener();
loadPDF(pdfBlob, filename, nbPDF);
}; };
(function () { (function () {
@ -782,8 +773,6 @@ var pageOrganization = async function(url) {
let hashUrl = window.location.hash.replace(/^\#/, ''); let hashUrl = window.location.hash.replace(/^\#/, '');
pageUpload(); pageUpload();
uploadFromUrl(hashUrl); uploadFromUrl(hashUrl);
} else if(window.location.hash) {
pageOrganization('/pdf/'+window.location.hash.replace(/^\#/, ''));
} else { } else {
pageUpload(); pageUpload();
} }

View File

@ -17,6 +17,8 @@ var menuOffcanvas = null;
var currentCursor = null; var currentCursor = null;
var signaturePad = null; var signaturePad = null;
var nblayers = null; var nblayers = null;
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'];
@ -135,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;
@ -495,9 +501,15 @@ var addObjectInCanvas = function(canvas, item) {
}; };
var createAndAddSvgInCanvas = function(canvas, item, x, y, height = null) { var createAndAddSvgInCanvas = function(canvas, item, x, y, height = null) {
if(document.querySelector('#alert-signature-help')) {
document.querySelector('#alert-signature-help').classList.add('d-none');
}
if(document.getElementById('save')) { if(document.getElementById('save')) {
document.getElementById('save').removeAttribute('disabled'); document.getElementById('save').removeAttribute('disabled');
} }
hasModifications = true;
if(document.getElementById('save_mobile')) { if(document.getElementById('save_mobile')) {
document.getElementById('save_mobile').removeAttribute('disabled'); document.getElementById('save_mobile').removeAttribute('disabled');
} }
@ -526,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();
@ -709,6 +723,10 @@ var createEventsListener = function() {
} }
document.querySelector('#'+svg_list_id+' label:last-child').click(); document.querySelector('#'+svg_list_id+' label:last-child').click();
if(document.querySelector('#save').disabled && document.querySelector('#alert-signature-help.auto-open') && !is_mobile()) {
document.querySelector('#alert-signature-help').classList.remove('d-none');
}
}); });
@ -762,6 +780,17 @@ var createEventsListener = function() {
event.preventDefault(); event.preventDefault();
}); });
if(document.querySelector('#alert-signature-help')) {
document.getElementById('btn-signature-help').addEventListener('click', function(event) {
document.querySelector('#alert-signature-help').classList.remove('d-none');
event.preventDefault();
});
document.querySelector('#alert-signature-help .btn-close').addEventListener('click', function(event) {
document.querySelector('#alert-signature-help').classList.add('d-none');
event.preventDefault();
});
}
if(document.getElementById('save')) { if(document.getElementById('save')) {
document.getElementById('save').addEventListener('click', function(event) { document.getElementById('save').addEventListener('click', function(event) {
let dataTransfer = new DataTransfer(); let dataTransfer = new DataTransfer();
@ -771,6 +800,7 @@ var createEventsListener = function() {
})); }));
}) })
document.getElementById('input_svg').files = dataTransfer.files; document.getElementById('input_svg').files = dataTransfer.files;
hasModifications = false;
}); });
} }
@ -785,6 +815,7 @@ var createEventsListener = function() {
}) })
} }
document.getElementById('input_svg_share').files = dataTransfer.files; document.getElementById('input_svg_share').files = dataTransfer.files;
hasModifications = false;
}); });
} }
@ -904,6 +935,10 @@ var createEventsListener = function() {
}); });
window.addEventListener('beforeunload', function(event) { window.addEventListener('beforeunload', function(event) {
if(!hasModifications) {
return;
}
event.preventDefault(); event.preventDefault();
return true; return true;
}); });
@ -1001,7 +1036,14 @@ var pageUpload = async function() {
document.getElementById('page-upload').classList.remove('d-none'); document.getElementById('page-upload').classList.remove('d-none');
document.getElementById('page-signature').classList.add('d-none'); document.getElementById('page-signature').classList.add('d-none');
document.getElementById('input_pdf_upload').focus(); document.getElementById('input_pdf_upload').focus();
const cache = await caches.open('pdf'); let cache;
try {
cache = await caches.open('pdf');
} catch (e) {
console.error(e)
alert("Erreur d'accès au cache. Cette application ne fonctionne pas en mode de navigation privée");
return;
}
document.getElementById('input_pdf_upload').addEventListener('change', async function(event) { document.getElementById('input_pdf_upload').addEventListener('change', async function(event) {
if(document.getElementById('input_pdf_upload').files[0].size > maxSize) { if(document.getElementById('input_pdf_upload').files[0].size > maxSize) {
@ -1055,6 +1097,10 @@ var pageSignature = async function(url) {
svgCollections = JSON.parse(localStorage.getItem('svgCollections')); svgCollections = JSON.parse(localStorage.getItem('svgCollections'));
} }
if(svgCollections.length == 0 && document.querySelector('#alert-signature-help')) {
document.querySelector('#alert-signature-help').classList.add('auto-open');
}
opentype.load('/vendor/fonts/Caveat-Regular.ttf', function(err, font) { opentype.load('/vendor/fonts/Caveat-Regular.ttf', function(err, font) {
fontCaveat = font; fontCaveat = font;
}); });

View File

@ -7,7 +7,7 @@
<link href="/vendor/bootstrap.min.css?5.1.1" rel="stylesheet"> <link href="/vendor/bootstrap.min.css?5.1.1" rel="stylesheet">
<link href="/vendor/bootstrap-icons.css?1.5.0" rel="stylesheet"> <link href="/vendor/bootstrap-icons.css?1.5.0" rel="stylesheet">
<link href="/css/app.css?202210080134" rel="stylesheet"> <link href="/css/app.css?<?php echo ($COMMIT) ? $COMMIT : filemtime($ROOT."/public/css/app.css") ?>" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="/favicon-metadata.ico"> <link rel="icon" type="image/x-icon" href="/favicon-metadata.ico">
<title>Édition des métadonnées d'un PDF</title> <title>Édition des métadonnées d'un PDF</title>
@ -35,7 +35,7 @@
<p class="fw-light mb-3 subtitle text-dark text-nowrap" style="overflow: hidden; text-overflow: ellipsis;">Ajouter, modifier ou supprimer les métadonnées d'un PDF</p> <p class="fw-light mb-3 subtitle text-dark text-nowrap" style="overflow: hidden; text-overflow: ellipsis;">Ajouter, modifier ou supprimer les métadonnées d'un PDF</p>
<div class="col-md-6 col-lg-5 col-xl-4 col-xxl-3 mx-auto"> <div class="col-md-6 col-lg-5 col-xl-4 col-xxl-3 mx-auto">
<div class="col-12"> <div class="col-12">
<label class="form-label mt-3" for="input_pdf_upload">Choisir un PDF <small class="opacity-75" style="cursor: help" title="Le PDF ne doit pas dépasser <?php echo round($maxSize / 1024 / 1024) ?> Mo"><i class="bi bi-info-circle"></i></small></label> <label class="form-label mt-3" for="input_pdf_upload">Choisir un PDF</label>
<input id="input_pdf_upload" placeholder="Choisir un PDF" class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" /> <input id="input_pdf_upload" placeholder="Choisir un PDF" class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" />
<p class="mt-2 small fw-light text-dark">&nbsp;</p> <p class="mt-2 small fw-light text-dark">&nbsp;</p>
<?php if($PDF_DEMO_LINK): ?> <?php if($PDF_DEMO_LINK): ?>
@ -45,7 +45,7 @@
</div> </div>
</div> </div>
<footer class="text-center text-muted mb-2 fixed-bottom opacity-75"> <footer class="text-center text-muted mb-2 fixed-bottom opacity-75">
<small>Logiciel libre <span class="d-none d-md-inline">sous license AGPL-3.0 </span>: <a href="https://github.com/24eme/signaturepdf">voir le code source</a></small> <small>Logiciel libre <span class="d-none d-md-inline">sous license AGPL-3.0</span> : <a href="https://github.com/24eme/signaturepdf">voir le code source </a><?php if($COMMIT): ?> <span class="d-none d-md-inline small">[<a href="https://github.com/24eme/signaturepdf/tree/<?php echo $COMMIT ?>"><?php echo $COMMIT ?></a>]</span><?php endif; ?></small>
</footer> </footer>
</div> </div>
<div id="page-metadata" class="d-none"> <div id="page-metadata" class="d-none">
@ -102,6 +102,6 @@
<script> <script>
var defaultFields = <?php echo json_encode(isset($METADATA_DEFAULT_FIELDS) ? $METADATA_DEFAULT_FIELDS : array()); ?>; var defaultFields = <?php echo json_encode(isset($METADATA_DEFAULT_FIELDS) ? $METADATA_DEFAULT_FIELDS : array()); ?>;
</script> </script>
<script src="/js/metadata.js?202304201611"></script> <script src="/js/metadata.js?<?php echo ($COMMIT) ? $COMMIT : filemtime($ROOT."/public/js/metadata.js") ?>"></script>
</body> </body>
</html> </html>

View File

@ -7,7 +7,7 @@
<link href="/vendor/bootstrap.min.css?5.1.1" rel="stylesheet"> <link href="/vendor/bootstrap.min.css?5.1.1" rel="stylesheet">
<link href="/vendor/bootstrap-icons.css?1.5.0" rel="stylesheet"> <link href="/vendor/bootstrap-icons.css?1.5.0" rel="stylesheet">
<link href="/css/app.css?202210080134" rel="stylesheet"> <link href="/css/app.css?<?php echo ($COMMIT) ? $COMMIT : filemtime($ROOT."/public/css/app.css") ?>" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="/favicon-organization.ico"> <link rel="icon" type="image/x-icon" href="/favicon-organization.ico">
<title>Organiser un PDF</title> <title>Organiser un PDF</title>
@ -36,7 +36,7 @@
<div class="col-md-6 col-lg-5 col-xl-4 col-xxl-3 mx-auto"> <div class="col-md-6 col-lg-5 col-xl-4 col-xxl-3 mx-auto">
<div class="col-12"> <div class="col-12">
<label class="form-label mt-3" for="input_pdf_upload">Choisir un PDF <small class="opacity-75" style="cursor: help" title="Le PDF ne doit pas dépasser <?php echo round($maxSize / 1024 / 1024) ?> Mo"><i class="bi bi-info-circle"></i></small></label> <label class="form-label mt-3" for="input_pdf_upload">Choisir un PDF <small class="opacity-75" style="cursor: help" title="Le PDF ne doit pas dépasser <?php echo round($maxSize / 1024 / 1024) ?> Mo"><i class="bi bi-info-circle"></i></small></label>
<input id="input_pdf_upload" placeholder="Choisir un PDF" class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" /> <input id="input_pdf_upload" placeholder="Choisir un PDF" class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" multiple="true" />
<p class="mt-2 small fw-light text-dark">Le PDF sera traité par le serveur sans être conservé ni stocké</p> <p class="mt-2 small fw-light text-dark">Le PDF sera traité par le serveur sans être conservé ni stocké</p>
<?php if($PDF_DEMO_LINK): ?> <?php if($PDF_DEMO_LINK): ?>
<a class="btn btn-sm btn-link opacity-75" href="#<?php echo $PDF_DEMO_LINK ?>">Tester avec un PDF de démo</a> <a class="btn btn-sm btn-link opacity-75" href="#<?php echo $PDF_DEMO_LINK ?>">Tester avec un PDF de démo</a>
@ -45,7 +45,7 @@
</div> </div>
</div> </div>
<footer class="text-center text-muted mb-2 fixed-bottom opacity-75"> <footer class="text-center text-muted mb-2 fixed-bottom opacity-75">
<small>Logiciel libre <span class="d-none d-md-inline">sous license AGPL-3.0 </span>: <a href="https://github.com/24eme/signaturepdf">voir le code source</a></small> <small>Logiciel libre <span class="d-none d-md-inline">sous license AGPL-3.0</span> : <a href="https://github.com/24eme/signaturepdf">voir le code source </a><?php if($COMMIT): ?> <span class="d-none d-md-inline small">[<a href="https://github.com/24eme/signaturepdf/tree/<?php echo $COMMIT ?>"><?php echo $COMMIT ?></a>]</span><?php endif; ?></small>
</footer> </footer>
</div> </div>
<div id="page-organization" style="padding-right: 350px;" class="d-none"> <div id="page-organization" style="padding-right: 350px;" class="d-none">
@ -157,6 +157,6 @@
<script> <script>
var maxSize = <?php echo $maxSize ?>; var maxSize = <?php echo $maxSize ?>;
</script> </script>
<script src="/js/organization.js?202212070154"></script> <script src="/js/organization.js?<?php echo ($COMMIT) ? $COMMIT : filemtime($ROOT."/public/js/organization.js") ?>"></script>
</body> </body>
</html> </html>

View File

@ -7,7 +7,7 @@
<meta name="description" content="Logiciel libre de signature de PDF en ligne"> <meta name="description" content="Logiciel libre de signature de PDF en ligne">
<link href="/vendor/bootstrap.min.css?5.1.1" rel="stylesheet"> <link href="/vendor/bootstrap.min.css?5.1.1" rel="stylesheet">
<link href="/vendor/bootstrap-icons.css?1.8.1" rel="stylesheet"> <link href="/vendor/bootstrap-icons.css?1.8.1" rel="stylesheet">
<link href="/css/app.css" rel="stylesheet"> <link href="/css/app.css?<?php echo ($COMMIT) ? $COMMIT : filemtime($ROOT."/public/css/app.css") ?>" rel="stylesheet">
<title>Signature PDF</title> <title>Signature PDF</title>
</head> </head>
<body> <body>
@ -45,10 +45,20 @@
</div> </div>
</div> </div>
<footer class="text-center text-muted mb-2 fixed-bottom opacity-75"> <footer class="text-center text-muted mb-2 fixed-bottom opacity-75">
<small>Logiciel libre <span class="d-none d-md-inline">sous license AGPL-3.0 </span>: <a href="https://github.com/24eme/signaturepdf">voir le code source</a></small> <small>Logiciel libre <span class="d-none d-md-inline">sous license AGPL-3.0</span> : <a href="https://github.com/24eme/signaturepdf">voir le code source </a><?php if($COMMIT): ?> <span class="d-none d-md-inline small">[<a href="https://github.com/24eme/signaturepdf/tree/<?php echo $COMMIT ?>"><?php echo $COMMIT ?></a>]</span><?php endif; ?></small>
</footer> </footer>
</div> </div>
<div id="page-signature" style="padding-right: 350px;" class="d-none"> <div id="page-signature" style="padding-right: 350px;" class="d-none">
<?php if(isset($hash)): ?>
<div id="alert-signature-help" class="position-relative d-none">
<div class="alert alert-primary alert-dismissible position-absolute top-0 start-50 translate-middle-x text-center mt-4 pb-2 w-50 opacity-100" style="z-index: 100;" role="alert">
<h5 class="alert-heading">Comment signer ?</h5>
<strong>En cliquant directement sur la page du document</strong> pour insérer l'élément séléctionné dans la colonne de droite <small>(signature, paraphe, texte, tampon, etc ...)</small>
<div class="mt-1 fs-3"><i class="bi bi-box-arrow-down"></i></div>
<button type="button" class="btn-close btn-sm" aria-label="Close"></button>
</div>
</div>
<?php endif; ?>
<div style="height: 65px;" class="d-md-none"></div> <div style="height: 65px;" class="d-md-none"></div>
<div id="container-pages" class="col-12 pt-1 pb-1 text-center vh-100"> <div id="container-pages" class="col-12 pt-1 pb-1 text-center vh-100">
</div> </div>
@ -104,8 +114,10 @@
<button class="btn btn-primary w-100 mt-2" disabled="disabled" type="submit" id="save"><i class="bi bi-download"></i> Télécharger le PDF signé</button> <button class="btn btn-primary w-100 mt-2" disabled="disabled" type="submit" id="save"><i class="bi bi-download"></i> Télécharger le PDF signé</button>
</form> </form>
<?php elseif(!isset($noSharingMode)): ?> <?php elseif(!isset($noSharingMode)): ?>
<div class="d-none d-sm-none d-md-block"> <div class="d-none d-sm-none d-md-block position-relative">
<p id="nblayers_text" class="small d-none mb-2 opacity-75">Vous êtes <span class="badge rounded-pill border border-dark text-dark"><span class="nblayers">0</span> <i class="bi bi-people-fill"></i></span> à avoir signé ce PDF</p></div> <a id="btn-signature-help" class="position-absolute top-0 end-0 text-dark" href="" style="z-index: 5;"><i class="bi bi-question-circle"></i></a>
<p id="nblayers_text" class="small d-none mb-2 opacity-75">Vous êtes <span class="badge rounded-pill border border-dark text-dark"><span class="nblayers">0</span> <i class="bi bi-people-fill"></i></span> à avoir signé ce PDF</p>
</div>
<div class="btn-group w-100"> <div class="btn-group w-100">
<a id="btn_download" class="btn btn-outline-dark w-100" href="/signature/<?php echo $hash ?>/pdf"><i class="bi bi-download"></i> Télécharger le PDF</a> <a id="btn_download" class="btn btn-outline-dark w-100" href="/signature/<?php echo $hash ?>/pdf"><i class="bi bi-download"></i> Télécharger le PDF</a>
<button class="btn btn-outline-dark" type="button" id="btn_share" data-bs-toggle="modal" data-bs-target="#modal-share-informations"><i class="bi bi-share"></i></button> <button class="btn btn-outline-dark" type="button" id="btn_share" data-bs-toggle="modal" data-bs-target="#modal-share-informations"><i class="bi bi-share"></i></button>
@ -265,6 +277,6 @@
hash = "<?php echo $hash ?>"; hash = "<?php echo $hash ?>";
<?php endif; ?> <?php endif; ?>
</script> </script>
<script src="/js/signature.js?202204270035"></script> <script src="/js/signature.js?<?php echo ($COMMIT) ? $COMMIT : filemtime($ROOT."/public/js/signature.js") ?>"></script>
</body> </body>
</html> </html>