1
0
Fork 0
mirror of https://github.com/24eme/signaturepdf synced 2024-05-21 07:06:41 +02:00

update read me + adding several compression intensity levels

This commit is contained in:
tale-fau 2023-09-21 16:33:27 +02:00
parent f26e79e252
commit 8a427e82bb
6 changed files with 460 additions and 475 deletions

View file

@ -1,329 +0,0 @@
<sup>[Français](README.md) | **[English](README.en.md)**</sup>
# PDF Signature
Free web software for signing PDFs.
## Instances
List of instances where you can use this software:
- [pdf.24eme.fr](https://pdf.24eme.fr)
- [pdf.libreon.fr](https://pdf.libreon.fr)
- [pdf.hostux.net](https://pdf.hostux.net)
- [pdf.nebulae.co](https://pdf.nebulae.co)
_Feel free to add yours through an issue or a pull request._
## License
Open-source software under the AGPL V3 license.
## Installation
### Debian/Ubuntu
Dependencies:
- php >= 5.6
- rsvg-convert
- pdftk
- imagemagick
- potrace
Installing dependencies:
```
sudo aptitude install php librsvg2-bin pdftk imagemagick potrace
```
Getting the source code:
```
git clone https://github.com/24eme/signaturepdf.git
```
To run it:
```
php -S localhost:8000 -t public
```
#### PHP Configuration
```
upload_max_filesize = 24M # Maximum size of the PDF file to sign
post_max_size = 24M # Maximum size of the PDF file to sign
max_file_uploads = 201 # Maximum number of pages in the PDF, here 200 pages + the original PDF
```
#### Apache Configuration
```
DocumentRoot /path/to/signaturepdf/public
<Directory /path/to/signaturepdf/public>
Require all granted
FallbackResource /index.php
php_value max_file_uploads 201
php_value upload_max_filesize 24M
php_value post_max_size 24M
</Directory>
```
### Deploy with Docker
#### Building the image
```bash
docker build -t signaturepdf .
```
#### Running a container
```bash
docker run -d --name=signaturepdf -p 8080:80 signaturepdf
```
[localhost:8080](http://localhost:8080)
#### Configuration
The following variables can be used to configure the deployment:
| Variable | description | exemple | defaut |
| ---------------------- |-----------------------------------------------------------------------| -------------------------------- | --------- |
| `SERVERNAME` | Deployment URL | `pdf.24eme.fr` | localhost |
| `UPLOAD_MAX_FILESIZE` | Maximum size of the PDF file to sign | 48M | 24M |
| `POST_MAX_SIZE` | Maximum size of the PDF file to sign | 48M | 24M |
| `MAX_FILE_UPLOADS` | Maximum number of pages in the PDF, here 200 pages + the original PDF | 401 | 201 |
| `PDF_STORAGE_PATH` | Path where uploaded PDF files can be stored | /data | /data |
| `DISABLE_ORGANIZATION` | Disable the Organize route | true | false |
| `PDF_DEMO_LINK` | Show, hide, or change the demo PDF link | false, `link` or `relative path` | true |
```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
```
### Alpine
Here is a script to install the solution on Linux Alpine (tested with version 3.15).
Remember to edit the "domain" variable at the beginning of the script to match the URL it will be called with.
The main components are:
- php 8 + php-fpm
- Nginx
- pdftk ("manual" installation requiring openjdk8)
- imagick
- potrace
- librsvg
What the script does:
- Installs dependencies
- Configures php and php-fpm
- Configures Nginx
- Configures the config.ini
- Clones the repo
```
#!/bin/sh
domain='sign.example.com'
apk update
apk add bash nginx git php8 php8-fpm php8-session php8-gd php8-fileinfo openjdk8 imagemagick potrace librsvg
cd /tmp
wget https://gitlab.com/pdftk-java/pdftk/-/jobs/924565145/artifacts/raw/build/libs/pdftk-all.jar
mv pdftk-all.jar pdftk.jar
cat <<EOF >>pdftk
#!/usr/bin/env bash
/usr/bin/java -jar "\$0.jar" "\$@"
EOF
chmod 775 pdftk*
mv pdftk* /usr/bin
sed -i 's/user = nobody/user = nginx/g' /etc/php8/php-fpm.d/www.conf
sed -i 's/;listen.owner = nginx/listen.owner = nginx/g' /etc/php8/php-fpm.d/www.conf
sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php8/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php8/php.ini
sed -i 's/max_file_uploads = 20 /max_file_uploads = 300/g' /etc/php8/php.ini
service php-fpm8 restart
cd /var/www
git clone https://github.com/24eme/signaturepdf.git
cat <<EOF >>/etc/nginx/http.d/signaturepdf.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name ${domain};
client_max_body_size 0;
root /var/www/signaturepdf/public/;
index index.php index.html;
location / {
# URLs to attempt, including pretty ones.
try_files \$uri \$uri/ /index.php?\$query_string;
}
location ~ [^/]\.php(/|$) {
root /var/www/signaturepdf/public/;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 128 128k;
fastcgi_param PATH_INFO \$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
EOF
rm /etc/nginx/http.d/default.conf
rm -R /var/www/localhost
service nginx restart
rc-update add nginx
rc-update add php-fpm8
mkdir /var/www/signaturepdf/tmp
chown nginx /var/www/signaturepdf/tmp
cat <<EOF >>/var/www/signaturepdf/config/config.ini
PDF_STORAGE_PATH=/var/www/signaturepdf/tmp
EOF
```
## Configuration
### Enabling and Configuring Multi-Signature Mode
This mode allows multiple people to sign a PDF, but it requires that the PDFs be stored on the server.
It is not mandatory to enable this mode for the application to work; it is an option.
Create the `config/config.ini` file
```
cp config/config.ini{.example,}
```
In the `config/config.ini` file, configure the `PDF_STORAGE_PATH` variable with the path where uploaded PDF files can be stored:
```
PDF_STORAGE_PATH=/path/to/folder
```
Create this folder:
```
mkdir /path/to/folder
```
The web server should have write permissions on this folder.
For example, for Apache:
```
chown www-data /path/to/folder/to/store/pdf
```
### Disabling the Organize Mode
To disable the Organize mode, add `DISABLE_ORGANIZATION=true` to the
`config/config.ini` file.
### Hiding or Modifying the Demo PDF Link
To hide the demo PDF link, add `PDF_DEMO_LINK=false` to the
`config/config.ini` file.
### Default Fields for Metadata Editing
In the `config/config.ini` file, you can add as many fields as you want with the HTML input type (text, date, number, email, etc.) that will be preloaded for each PDF.
```
METADATA_DEFAULT_FIELDS[field1].type = "text"
METADATA_DEFAULT_FIELDS[field2].type = "text"
METADATA_DEFAULT_FIELDS[field3].type = "date"
METADATA_DEFAULT_FIELDS[field4].type = "number"
```
## Update
The latest stable version is on the `master` branch. To update, simply fetch the latest changes:
```
git pull -r
```
## Tests
To run functional tests:
```
make test
```
The tests are performed using `puppeteer` and `jest`.
To run the tests and view the browser (in debug mode):
```
DEBUG=1 make test
```
## Libraries Used
- **Fat-Free** PHP micro framework: https://github.com/bcosca/fatfree (GPLv3)
- **Bootstrap** HTML, CSS, and JavaScript framework: https://getbootstrap.com/ (MIT)
- **PDF.js** JavaScript library for rendering PDFs in an HTML canvas: https://github.com/mozilla/pdf.js (Apache-2.0)
- **Fabric.js** JavaScript library for manipulating an HTML canvas: https://github.com/fabricjs/fabric.js (MIT)
- **PDFtk** PDF manipulation tools (GPL)
- **librsvg** SVG manipulation tools: https://gitlab.gnome.org/GNOME/librsvg (LGPL-2+)
- **potrace** Bitmap to vector image conversion tools: http://potrace.sourceforge.net/ (GPLv2)
- **OpenType.js** Tools for converting text and its font into paths: https://github.com/opentypejs/opentype.js (MIT)
- **ImageMagick** Image manipulation toolset: https://imagemagick.org/ (Apache-2.0)
- **Caveat** Handwriting-style font: https://github.com/googlefonts/caveat (OFL-1.1)
- **PDF-LIB** JavaScript library for PDF manipulation used for writing metadata: https://pdf-lib.js.org/ (MIT)
For testing:
- **Jest** JavaScript Testing Framework: https://jestjs.io/ (MIT)
- **Puppeteer** Node.js library for controlling a web browser: https://github.com/puppeteer/puppeteer (Apache-2.0)
## Contributions
### Translation
To update the translation, simply execute `make` that will update the `.pot` file,
which will merge the `.po` files which then will allow to create updated `.mo` files.
Translations might be added on Weblate : https://hosted.weblate.org/projects/signature-pdf/application/
### Contributors
These people are the authors of the code of this software :
Vincent LAURENT (24ème), Jean-Baptiste Le Metayer (24ème), Xavier Garnier (Logilab), Simon Chabot (Logilab), Tangui Morlier (24ème), Gabriel POMA (24ème), Tanguy Le Faucheur (24ème), Étienne Deparis, battosai30
### Fundings
- 1 365 € excl. taxes from the company Logilab for the development of the shared signature feature
- 1 950 € excl. taxes from the company Logilab for the development of the metadata editing feature
- 100 € excl. taxes donations from the company Spirkop
- 100 € excl. taxes donations from the company PDG IT
- 1 040 € excl. taxes from the foundation NLNet pour software internationalization
The development of the software was primarily done during the working hours of 24ème employees.

336
README.fr.md Normal file
View file

@ -0,0 +1,336 @@
<sup>**[Français](README.md)** | [English](README.en.md)</sup>
# Signature de PDF
Logiciel web libre permettant de signer un PDF.
## Instances
Liste des instances permettant d'utiliser ce logiciel :
- [pdf.24eme.fr](https://pdf.24eme.fr)
- [pdf.libreon.fr](https://pdf.libreon.fr)
- [pdf.hostux.net](https://pdf.hostux.net)
- [pdf.nebulae.co](https://pdf.nebulae.co)
_N'hésitez pas à rajouter la votre via une issue ou une pull request_
## License
Logiciel libre sous license AGPL V3
## Installation
### Debian/Ubuntu
Dépendances :
- php >= 5.6
- rsvg-convert
- pdftk
- imagemagick
- potrace
Installation des dépendances :
```
sudo aptitude install php librsvg2-bin pdftk imagemagick potrace
```
Récupération des sources :
```
git clone https://github.com/24eme/signaturepdf.git
```
Pour le lancer :
```
php -S localhost:8000 -t public
```
#### Configuration de PHP
```
upload_max_filesize = 24M # Taille maximum du fichier PDF à signer
post_max_size = 24M # Taille maximum du fichier PDF à signer
max_file_uploads = 201 # Nombre de pages maximum du PDF, ici 200 pages + le PDF d'origine
```
#### Configuration d'apache
```
DocumentRoot /path/to/signaturepdf/public
<Directory /path/to/signaturepdf/public>
Require all granted
FallbackResource /index.php
php_value max_file_uploads 201
php_value upload_max_filesize 24M
php_value post_max_size 24M
</Directory>
```
### Déployer avec docker
#### Construction de l'image
```bash
docker build -t signaturepdf .
```
#### Lancement d'un conteneur
```bash
docker run -d --name=signaturepdf -p 8080:80 signaturepdf
```
[localhost:8080](http://localhost:8080)
#### Configuration
Les variables suivantes permettent de configurer le déployement :
| Variable | description | exemple | defaut |
| ---------------------- | ------------------------------------------------------------------ | -------------------------------- | --------- |
| `SERVERNAME` | url de déploiement | `pdf.24eme.fr` | localhost |
| `UPLOAD_MAX_FILESIZE` | 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 |
| `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 |
| `PDF_DEMO_LINK` | Afficher, retirer ou changer le lien de PDF de démo | false, `link` or `relative path` | true |
```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
```
### Alpine
Voici un script permettant d'installer la solution sous Linux Alpine (testé en version 3.15).
Pensez à éditer la variable "domain" en début de script pour correspondre à l'URL avec laquelle elle sera appelée.
Les composants principaux sont :
- php 8 + php-fpm
- Nginx
- pdftk (installation "manuelle" nécessitant openjdk8)
- imagick
- potrace
- librsvg
Ce que fait le script :
- Installation des dépendances
- Configuration de php et php-fpm
- Configuration d'Nginx
- Configuration du config.ini
- Git clone du repo
```
#!/bin/sh
domain='sign.example.com'
apk update
apk add bash nginx git php8 php8-fpm php8-session php8-gd php8-fileinfo openjdk8 imagemagick potrace librsvg
cd /tmp
wget https://gitlab.com/pdftk-java/pdftk/-/jobs/924565145/artifacts/raw/build/libs/pdftk-all.jar
mv pdftk-all.jar pdftk.jar
cat <<EOF >>pdftk
#!/usr/bin/env bash
/usr/bin/java -jar "\$0.jar" "\$@"
EOF
chmod 775 pdftk*
mv pdftk* /usr/bin
sed -i 's/user = nobody/user = nginx/g' /etc/php8/php-fpm.d/www.conf
sed -i 's/;listen.owner = nginx/listen.owner = nginx/g' /etc/php8/php-fpm.d/www.conf
sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php8/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php8/php.ini
sed -i 's/max_file_uploads = 20 /max_file_uploads = 300/g' /etc/php8/php.ini
service php-fpm8 restart
cd /var/www
git clone https://github.com/24eme/signaturepdf.git
cat <<EOF >>/etc/nginx/http.d/signaturepdf.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name ${domain};
client_max_body_size 0;
root /var/www/signaturepdf/public/;
index index.php index.html;
location / {
# URLs to attempt, including pretty ones.
try_files \$uri \$uri/ /index.php?\$query_string;
}
location ~ [^/]\.php(/|$) {
root /var/www/signaturepdf/public/;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 128 128k;
fastcgi_param PATH_INFO \$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
EOF
rm /etc/nginx/http.d/default.conf
rm -R /var/www/localhost
service nginx restart
rc-update add nginx
rc-update add php-fpm8
mkdir /var/www/signaturepdf/tmp
chown nginx /var/www/signaturepdf/tmp
cat <<EOF >>/var/www/signaturepdf/config/config.ini
PDF_STORAGE_PATH=/var/www/signaturepdf/tmp
EOF
```
## Configuration
### Activation et configuration du mode partage de signature à plusieurs
Ce mode permet de proposer la signature d'un pdf à plusieurs personnes mais il nécessite que les PDF soient stockés sur le serveur, il convient donc de définir un dossier qui contiendra ces PDF.
Il n'est pas obligatoire d'activer ce mode pour que l'application fonctionne c'est une option.
Créer le fichier `config/config.ini`
```
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 :
```
PDF_STORAGE_PATH=/path/to/folder
```
Créer ce dossier :
```
mkdir /path/to/folder
```
Le serveur web devra avoir les droits en écriture sur ce dossier.
Par exemple pour apache :
```
chown www-data /path/to/folder/to/store/pdf
```
### Desactivation du mode Organiser
Pour desactiver le mode Organiser, ajouter `DISABLE_ORGANIZATION=true` dans le fichier
`config/config.ini`.
### Cacher ou modifier le lien de PDF de démo
Pour cacher le lien de pdf de démo, ajouter `PDF_DEMO_LINK=false` dans le fichier
`config/config.ini`.
### Champs chargés par défaut pour l'édition de métadonnéés
Dans le fichier de configuration `config/config.ini` il est possible de rajouter autant de champs que l'on souhaite avec le type HTML de l'input (text, date, number email, etc ...) qui seront préchargées pour chaque PDF.
```
METADATA_DEFAULT_FIELDS[field1].type = "text"
METADATA_DEFAULT_FIELDS[field2].type = "text"
METADATA_DEFAULT_FIELDS[field3].type = "date"
METADATA_DEFAULT_FIELDS[field4].type = "number"
```
## Mise à jour
La dernière version stable est sur la branche `master`, pour la mise à jour il suffit de récupérer les dernières modifications :
```
git pull -r
```
## Tests
Pour exécuter les tests fonctionnels :
```
make test
```
Les tests sont réalisés avec `puppeteer` et `jest`.
Pour lancer les tests et voir le navigateur (en mode debug) :
```
DEBUG=1 make test
```
## Librairies utilisées
- **Fat-Free** micro framework PHP : https://github.com/bcosca/fatfree (GPLv3)
- **Bootstrap** framework html, css et javascript : https://getbootstrap.com/ (MIT)
- **PDF.js** librairie de lecture de PDF dans un canvas HTML : https://github.com/mozilla/pdf.js (Apache-2.0)
- **Fabric.js** librairie pour manipuler un canvas HTML : https://github.com/fabricjs/fabric.js (MIT)
- **PDFtk** outils de manipulation de PDF (GPL)
- **librsvg** outils de manipulation de SVG : https://gitlab.gnome.org/GNOME/librsvg (LGPL-2+)
- **potrace** outils de transformation d'image bitamp en image vectorisé : http://potrace.sourceforge.net/ (GPLv2)
- **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)
- **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 :
- **Jest** Framework de Test Javascript : https://jestjs.io/ (MIT)
- **Puppeteer** librairie Node.js pour contrôler un navigateur : https://github.com/puppeteer/puppeteer (Apache-2.0)
## Contributions
### Traductions
Pour mettre à jour la traduction, exécutez simplement `make` qui mettra a jour le fichier `.pot`,
qui fera un merge avec les fichiers `.po` qui permetteront de recréer les fichiers `.mo` mis a jour.
Des traductions peuvent etre ajoutées sur Weblate : https://hosted.weblate.org/projects/signature-pdf/application/
### Contributeurs
Ces personnes sont auteurices du code de ce logiciel :
Vincent LAURENT (24ème), Jean-Baptiste Le Metayer (24ème), Xavier Garnier (Logilab), Simon Chabot (Logilab), Tangui Morlier (24ème), Gabriel POMA (24ème), Tanguy Le Faucheur (24ème), Étienne Deparis, battosai30
### Financements
- 1 365 € HT de la société Logilab pour le développement du mode signature partagé à plusieurs
- 1 950 € HT de la société Logilab pour le développement de l'édition des métadonnées
- 100 € HT de don de la société Spirkop
- 100 € HT de don de la société PDG IT
- 1 040 € HT de la fondation NLNet pour l'internationalisation du logiciel
Les modules signature et organiser ont été réalisés sur le temps de travail de salariés du 24ème.

183
README.md
View file

@ -1,67 +1,57 @@
<sup>**[Français](README.md)** | [English](README.en.md)</sup>
# PDF Signature
# Signature de PDF
Logiciel web libre permettant de signer un PDF.
Free web software for signing PDFs.
## Instances
Liste des instances permettant d'utiliser ce logiciel :
List of instances where you can use this software:
- [pdf.24eme.fr](https://pdf.24eme.fr)
- [pdf.libreon.fr](https://pdf.libreon.fr)
- [pdf.hostux.net](https://pdf.hostux.net)
- [pdf.nebulae.co](https://pdf.nebulae.co)
_N'hésitez pas à rajouter la votre via une issue ou une pull request_
_Feel free to add yours through an issue or a pull request._
## License
Logiciel libre sous license AGPL V3
Open-source software under the AGPL V3 license.
## Installation
### Debian/Ubuntu
Dépendances :
Dependencies:
- php >= 5.6
- rsvg-convert
- pdftk
- imagemagick
- potrace
Installation des dépendances :
Installing dependencies:
```
sudo aptitude install php librsvg2-bin pdftk imagemagick potrace
```
Récupération des sources :
Getting the source code:
```
git clone https://github.com/24eme/signaturepdf.git
```
Pour le lancer :
To run it:
```
php -S localhost:8000 -t public
```
#### Configuration de PHP
#### PHP Configuration
```
upload_max_filesize = 24M # Taille maximum du fichier PDF à signer
post_max_size = 24M # Taille maximum du fichier PDF à signer
max_file_uploads = 201 # Nombre de pages maximum du PDF, ici 200 pages + le PDF d'origine
upload_max_filesize = 24M # Maximum size of the PDF file to sign
post_max_size = 24M # Maximum size of the PDF file to sign
max_file_uploads = 201 # Maximum number of pages in the PDF, here 200 pages + the original PDF
```
#### Configuration d'apache
#### Apache Configuration
```
DocumentRoot /path/to/signaturepdf/public
<Directory /path/to/signaturepdf/public>
Require all granted
FallbackResource /index.php
@ -71,15 +61,15 @@ DocumentRoot /path/to/signaturepdf/public
</Directory>
```
### Déployer avec docker
### Deploy with Docker
#### Construction de l'image
#### Building the image
```bash
docker build -t signaturepdf .
```
#### Lancement d'un conteneur
#### Running a container
```bash
docker run -d --name=signaturepdf -p 8080:80 signaturepdf
@ -89,17 +79,17 @@ docker run -d --name=signaturepdf -p 8080:80 signaturepdf
#### Configuration
Les variables suivantes permettent de configurer le déployement :
The following variables can be used to configure the deployment:
| Variable | description | exemple | defaut |
| ---------------------- | ------------------------------------------------------------------ | -------------------------------- | --------- |
| `SERVERNAME` | url de déploiement | `pdf.24eme.fr` | localhost |
| `UPLOAD_MAX_FILESIZE` | 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 |
| `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 |
| `PDF_DEMO_LINK` | Afficher, retirer ou changer le lien de PDF de démo | false, `link` or `relative path` | true |
| Variable | description | exemple | defaut |
| ---------------------- |-----------------------------------------------------------------------| -------------------------------- | --------- |
| `SERVERNAME` | Deployment URL | `pdf.24eme.fr` | localhost |
| `UPLOAD_MAX_FILESIZE` | Maximum size of the PDF file to sign | 48M | 24M |
| `POST_MAX_SIZE` | Maximum size of the PDF file to sign | 48M | 24M |
| `MAX_FILE_UPLOADS` | Maximum number of pages in the PDF, here 200 pages + the original PDF | 401 | 201 |
| `PDF_STORAGE_PATH` | Path where uploaded PDF files can be stored | /data | /data |
| `DISABLE_ORGANIZATION` | Disable the Organize route | true | false |
| `PDF_DEMO_LINK` | Show, hide, or change the demo PDF link | false, `link` or `relative path` | true |
```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
@ -107,25 +97,25 @@ docker run -d --name=signaturepdf -p 8080:80 -e SERVERNAME=pdf.example.org -e UP
### Alpine
Voici un script permettant d'installer la solution sous Linux Alpine (testé en version 3.15).
Pensez à éditer la variable "domain" en début de script pour correspondre à l'URL avec laquelle elle sera appelée.
Here is a script to install the solution on Linux Alpine (tested with version 3.15).
Remember to edit the "domain" variable at the beginning of the script to match the URL it will be called with.
Les composants principaux sont :
The main components are:
- php 8 + php-fpm
- Nginx
- pdftk (installation "manuelle" nécessitant openjdk8)
- pdftk ("manual" installation requiring openjdk8)
- imagick
- potrace
- librsvg
Ce que fait le script :
What the script does:
- Installation des dépendances
- Configuration de php et php-fpm
- Configuration d'Nginx
- Configuration du config.ini
- Git clone du repo
- Installs dependencies
- Configures php and php-fpm
- Configures Nginx
- Configures the config.ini
- Clones the repo
```
#!/bin/sh
@ -214,51 +204,51 @@ EOF
## Configuration
### Activation et configuration du mode partage de signature à plusieurs
### Enabling and Configuring Multi-Signature Mode
Ce mode permet de proposer la signature d'un pdf à plusieurs personnes mais il nécessite que les PDF soient stockés sur le serveur, il convient donc de définir un dossier qui contiendra ces PDF.
This mode allows multiple people to sign a PDF, but it requires that the PDFs be stored on the server.
Il n'est pas obligatoire d'activer ce mode pour que l'application fonctionne c'est une option.
It is not mandatory to enable this mode for the application to work; it is an option.
Créer le fichier `config/config.ini`
Create the `config/config.ini` file
```
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 :
In the `config/config.ini` file, configure the `PDF_STORAGE_PATH` variable with the path where uploaded PDF files can be stored:
```
PDF_STORAGE_PATH=/path/to/folder
```
Créer ce dossier :
Create this folder:
```
mkdir /path/to/folder
```
Le serveur web devra avoir les droits en écriture sur ce dossier.
The web server should have write permissions on this folder.
Par exemple pour apache :
For example, for Apache:
```
chown www-data /path/to/folder/to/store/pdf
```
### Desactivation du mode Organiser
### Disabling the Organize Mode
Pour desactiver le mode Organiser, ajouter `DISABLE_ORGANIZATION=true` dans le fichier
`config/config.ini`.
To disable the Organize mode, add `DISABLE_ORGANIZATION=true` to the
`config/config.ini` file.
### Cacher ou modifier le lien de PDF de démo
### Hiding or Modifying the Demo PDF Link
Pour cacher le lien de pdf de démo, ajouter `PDF_DEMO_LINK=false` dans le fichier
`config/config.ini`.
To hide the demo PDF link, add `PDF_DEMO_LINK=false` to the
`config/config.ini` file.
### Champs chargés par défaut pour l'édition de métadonnéés
### Default Fields for Metadata Editing
Dans le fichier de configuration `config/config.ini` il est possible de rajouter autant de champs que l'on souhaite avec le type HTML de l'input (text, date, number email, etc ...) qui seront préchargées pour chaque PDF.
In the `config/config.ini` file, you can add as many fields as you want with the HTML input type (text, date, number, email, etc.) that will be preloaded for each PDF.
```
METADATA_DEFAULT_FIELDS[field1].type = "text"
@ -267,9 +257,9 @@ METADATA_DEFAULT_FIELDS[field3].type = "date"
METADATA_DEFAULT_FIELDS[field4].type = "number"
```
## Mise à jour
## Update
La dernière version stable est sur la branche `master`, pour la mise à jour il suffit de récupérer les dernières modifications :
The latest stable version is on the `master` branch. To update, simply fetch the latest changes:
```
git pull -r
@ -277,60 +267,61 @@ git pull -r
## Tests
Pour exécuter les tests fonctionnels :
To run functional tests:
```
make test
```
Les tests sont réalisés avec `puppeteer` et `jest`.
The tests are performed using `puppeteer` and `jest`.
Pour lancer les tests et voir le navigateur (en mode debug) :
To run the tests and view the browser (in debug mode):
```
DEBUG=1 make test
```
## Librairies utilisées
## Libraries Used
- **Fat-Free** micro framework PHP : https://github.com/bcosca/fatfree (GPLv3)
- **Bootstrap** framework html, css et javascript : https://getbootstrap.com/ (MIT)
- **PDF.js** librairie de lecture de PDF dans un canvas HTML : https://github.com/mozilla/pdf.js (Apache-2.0)
- **Fabric.js** librairie pour manipuler un canvas HTML : https://github.com/fabricjs/fabric.js (MIT)
- **PDFtk** outils de manipulation de PDF (GPL)
- **librsvg** outils de manipulation de SVG : https://gitlab.gnome.org/GNOME/librsvg (LGPL-2+)
- **potrace** outils de transformation d'image bitamp en image vectorisé : http://potrace.sourceforge.net/ (GPLv2)
- **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)
- **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)
- **Fat-Free** PHP micro framework: https://github.com/bcosca/fatfree (GPLv3)
- **Bootstrap** HTML, CSS, and JavaScript framework: https://getbootstrap.com/ (MIT)
- **PDF.js** JavaScript library for rendering PDFs in an HTML canvas: https://github.com/mozilla/pdf.js (Apache-2.0)
- **Fabric.js** JavaScript library for manipulating an HTML canvas: https://github.com/fabricjs/fabric.js (MIT)
- **PDFtk** PDF manipulation tools (GPL)
- **librsvg** SVG manipulation tools: https://gitlab.gnome.org/GNOME/librsvg (LGPL-2+)
- **potrace** Bitmap to vector image conversion tools: http://potrace.sourceforge.net/ (GPLv2)
- **OpenType.js** Tools for converting text and its font into paths: https://github.com/opentypejs/opentype.js (MIT)
- **ImageMagick** Image manipulation toolset: https://imagemagick.org/ (Apache-2.0)
- **Caveat** Handwriting-style font: https://github.com/googlefonts/caveat (OFL-1.1)
- **PDF-LIB** JavaScript library for PDF manipulation used for writing metadata: https://pdf-lib.js.org/ (MIT)
Pour les tests :
For testing:
- **Jest** Framework de Test Javascript : https://jestjs.io/ (MIT)
- **Puppeteer** librairie Node.js pour contrôler un navigateur : https://github.com/puppeteer/puppeteer (Apache-2.0)
- **Jest** JavaScript Testing Framework: https://jestjs.io/ (MIT)
- **Puppeteer** Node.js library for controlling a web browser: https://github.com/puppeteer/puppeteer (Apache-2.0)
## Contributions
### Traductions
### Translation
Pour mettre à jour la traduction, exécutez simplement `make` qui mettra a jour le fichier `.pot`,
qui fera un merge avec les fichiers `.po` qui permetteront de recréer les fichiers `.mo` mis a jour.
To update the translation, simply execute `make` that will update the `.pot` file,
which will merge the `.po` files which then will allow to create updated `.mo` files.
Des traductions peuvent etre ajoutées sur Weblate : https://hosted.weblate.org/projects/signature-pdf/application/
Translations might be added on Weblate : https://hosted.weblate.org/projects/signature-pdf/application/
### Contributeurs
Ces personnes sont auteurices du code de ce logiciel :
### Contributors
These people are the authors of the code of this software :
Vincent LAURENT (24ème), Jean-Baptiste Le Metayer (24ème), Xavier Garnier (Logilab), Simon Chabot (Logilab), Tangui Morlier (24ème), Gabriel POMA (24ème), Tanguy Le Faucheur (24ème), Étienne Deparis, battosai30
### Financements
### Fundings
- 1 365 € HT de la société Logilab pour le développement du mode signature partagé à plusieurs
- 1 950 € HT de la société Logilab pour le développement de l'édition des métadonnées
- 100 € HT de don de la société Spirkop
- 100 € HT de don de la société PDG IT
- 1 040 € HT de la fondation NLNet pour l'internationalisation du logiciel
- 1 365 € excl. taxes from the company Logilab for the development of the shared signature feature
- 1 950 € excl. taxes from the company Logilab for the development of the metadata editing feature
- 100 € excl. taxes donations from the company Spirkop
- 100 € excl. taxes donations from the company PDG IT
- 1 040 € excl. taxes from the foundation NLNet pour software internationalization
Les modules signature et organiser ont été réalisés sur le temps de travail de salariés du 24ème.
The development of the software was primarily done during the working hours of 24ème employees.

11
app.php
View file

@ -406,11 +406,20 @@ $f3->route ('POST /compress',
}
});
$compressionType = $f3->get('POST.compressionType');
if ($compressionType === 'medium') {
$compressionType = '/ebook';
} elseif ($compressionType === 'low') {
$compressionType = '/printer';
} elseif ($compressionType === 'high') {
$compressionType = '/screen';
}
$arrayPath = array_keys($files);
$filePath = reset($arrayPath);
$outputFileName = str_replace(".pdf", "_compressed.pdf", $filePath);
$returnCode = shell_exec(sprintf("gs -sDEVICE=pdfwrite -dPDFSETTINGS=/screen -dQUIET -o %s %s", $outputFileName, $filePath));
$returnCode = shell_exec(sprintf("gs -sDEVICE=pdfwrite -dPDFSETTINGS=%s -dQUIET -o %s %s", $compressionType, $outputFileName, $filePath));
if ($returnCode !== false) {
header('Content-Type: application/pdf');

View file

@ -0,0 +1,13 @@
function handleFileChange() {
const fileInput = document.getElementById('input_pdf_upload');
const compressBtn = document.getElementById('compressBtn');
const dropdownCompressBtn = document.getElementById('dropdownMenuReference');
if (fileInput.files.length > 0) {
compressBtn.disabled = false;
dropdownCompressBtn.disabled = false;
} else {
compressBtn.disabled = true;
dropdownCompressBtn.disabled = true;
}
}

View file

@ -51,9 +51,19 @@
<div class="col-md-6 col-lg-5 col-xl-4 col-xxl-3 mx-auto">
<div class="col-12">
<label class="form-label mt-3" for="input_pdf_upload"><?php echo _("Choose a PDF"); ?></label>
<input name="input_pdf_upload" id="input_pdf_upload" placeholder="<?php echo _("Choose a PDF"); ?>" class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" />
<input name="input_pdf_upload" id="input_pdf_upload" placeholder="<?php echo _("Choose a PDF"); ?>" class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" onchange="handleFileChange()" />
<p class="mt-2 small fw-light text-dark">&nbsp;</p>
<button type="submit" id="compressBtn" class="btn btn-primary"><?php echo _("Compress"); ?></button>
<div class="btn-group">
<button type="submit" name="compressionType" value="medium" id="compressBtn" class="btn btn-primary" disabled><?php echo sprintf(_("%s Compress"), '<i class="bi bi-download"></i>'); ?></button>
<button type="button" id="dropdownMenuReference" class="btn btn-outline-primary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false" data-bs-reference="parent" disabled>
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuReference">
<button type="submit" name="compressionType" value="low" id="lowCompressBtn" class="dropdown-item"><?php echo _("Low compression (highest quality)"); ?></button>
<button type="submit" name="compressionType" value="medium" id="mediumCompressBtn" class="dropdown-item"><?php echo sprintf(_("%s Medium compression %s (default)"), "<strong>", "</strong>"); ?></strong></button>
<button type="submit" name="compressionType" value="high" id="highCompressBtn" class="dropdown-item"><?php echo _("High compression (lowest quality)"); ?></button>
</div>
</div>
</div>
</div>
</form>
@ -62,51 +72,6 @@
<small><?php echo _("Free open-source software"); ?> <span class="d-none d-md-inline"><?php echo _("under AGPL-3.0 license"); ?></span> : <a href="https://github.com/24eme/signaturepdf"><?php echo _("see the source code"); ?></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>
</div>
<!--<div id="page-metadata" class="d-none">
<div id="div-margin-top" style="height: 88px;" class="d-md-none"></div>
<div style="width: 60%; overflow: auto;" class="vh-100" id="container-main">
<div id="form-metadata" class="mx-auto w-75 pt-3 pb-5">
<h3><?php /*echo _("List of PDF metadata"); */?></h3>
<div id="form-metadata-container">
</div>
<form id="form_metadata_add" class="position-relative">
<hr class="text-muted mt-4 mb-3" />
<div class="mb-3">
<label class="form-label text-muted" for="input_metadata_key"><?php /*echo _("Add new metadata"); */?></label>
<div class="form-floating">
<input id="input_metadata_key" name="metadata_key" type="text" class="form-control" required value="" style="border-bottom-right-radius: 0; border-bottom-left-radius: 0;">
<label><?php /*echo _("Key"); */?></label>
</div>
<input id="input_metadata_value" readonly="readonly" style="border-top: 0; border-top-right-radius: 0; border-top-left-radius: 0;" name="metadata_value" type="text" class="form-control bg-light opacity-50" value="" placeholder="<?php /*echo _("Value"); */?>" style="border-bottom-right-radius: 0; border-bottom-left-radius: 0;">
</div>
<button type="submit" type="button" class="btn btn-outline-secondary float-end"><?php /*echo sprintf(_("%s Add"), '<i class="bi bi-plus-circle"></i>'); */?></button>
</form>
</div>
</div>
<div id="div-margin-bottom" style="height: 55px;" class="d-md-none"></div>
<div style="width: 40%;" class="offcanvas offcanvas-end show d-none d-md-block shadow-sm" data-bs-backdrop="false" data-bs-scroll="true" data-bs-keyboard="false" tabindex="-1" id="sidebarTools" aria-labelledby="sidebarToolsLabel">
<a class="btn btn-close btn-sm position-absolute opacity-25 d-none d-sm-none d-md-block" title="<?php /*echo _("Close this PDF and return to the home page"); */?>" style="position: absolute; top: 2px; right: 2px; font-size: 10px;" href="/metadata"></a>
<div class="offcanvas-header d-block mb-0 pb-0 border-bottom">
<h5 class="mb-1 d-block w-100" id="sidebarToolsLabel"><?php /*echo _("Edit metadata"); */?><span class=\"float-end me-2\"><i class=\"bi bi-tags\"></i></span></h5>
<button type="button" class="btn-close text-reset d-md-none" data-bs-dismiss="offcanvas" aria-label="Close"></button>
<p id="text_document_name" class="text-muted mb-2" style="text-overflow: ellipsis; white-space: nowrap; overflow: hidden;" title=""><i class="bi bi-files"></i> <span></span></p>
</div>
<div class="offcanvas-body bg-light" style="padding-bottom: 60px;">
<div id="container-pages">
</div>
</div>
<div class="position-absolute bg-white bottom-0 pb-2 ps-2 pe-2 w-100 border-top shadow-lg">
<div id="btn_container" class="d-grid gap-2 mt-2">
<button class="btn btn-primary" type="submit" id="save"><i class="bi bi-download"></i> <?php /*echo _("Save and download the PDF"); */?></button>
</div>
</div>
</div>
<div id="bottom_bar" class="position-fixed bottom-0 start-0 bg-white w-100 p-2 shadow-sm d-md-none">
<div id="bottom_bar_action" class="d-grid gap-2">
<button class="btn btn-primary" id="save_mobile"><i class="bi bi-download"></i> <?php /*echo _("Download the PDF"); */?></button>
</div>
</div>
</div>-->
<span id="is_mobile" class="d-md-none"></span>
<script src="<?php echo $REVERSE_PROXY_URL; ?>/vendor/bootstrap.bundle.min.js?5.1.3"></script>
@ -115,6 +80,6 @@
<script>
var defaultFields = <?php echo json_encode(isset($METADATA_DEFAULT_FIELDS) ? $METADATA_DEFAULT_FIELDS : array()); ?>;
</script>
<!--<script src="<?php /*echo $REVERSE_PROXY_URL; */?>/js/compress.js?<?php /*echo ($COMMIT) ? $COMMIT : filemtime($ROOT."/public/js/compress.js") */?>"></script>
--></body>
<script src="<?php echo $REVERSE_PROXY_URL; ?>/js/compress.js?<?php echo ($COMMIT) ? $COMMIT : filemtime($ROOT."/public/js/compress.js") ?>"></script>
</body>
</html>