1
0
Fork 0
mirror of https://github.com/24eme/signaturepdf synced 2024-06-18 13:45:07 +02:00
24eme-signaturepdf/README.md

330 lines
9.8 KiB
Markdown
Raw Normal View History

# PDF Signature
2021-05-04 00:50:11 +02:00
Free web software for signing PDFs.
2023-09-14 17:29:33 +02:00
## Instances
List of instances where you can use this software:
- [pdf.24eme.fr](https://pdf.24eme.fr)
2022-01-28 18:24:01 +01:00
- [pdf.libreon.fr](https://pdf.libreon.fr)
2022-10-07 11:29:37 +02:00
- [pdf.hostux.net](https://pdf.hostux.net)
2022-10-07 13:27:57 +02:00
- [pdf.nebulae.co](https://pdf.nebulae.co)
_Feel free to add yours through an issue or a pull request._
2022-10-07 14:05:07 +02:00
2021-05-04 00:50:11 +02:00
## License
Open-source software under the AGPL V3 license.
2021-05-04 00:50:11 +02:00
## Installation
2022-07-08 11:38:39 +02:00
### Debian/Ubuntu
Dependencies:
2023-04-21 12:32:55 +02:00
- php >= 5.6
2021-05-04 00:50:11 +02:00
- rsvg-convert
- pdftk
2021-09-21 18:11:47 +02:00
- imagemagick
2021-09-21 01:51:27 +02:00
- potrace
2021-05-04 00:50:11 +02:00
Installing dependencies:
2021-10-24 01:47:23 +02:00
```
2021-09-21 18:11:47 +02:00
sudo aptitude install php librsvg2-bin pdftk imagemagick potrace
2021-10-24 01:47:23 +02:00
```
2021-05-04 00:50:11 +02:00
Getting the source code:
2021-05-04 00:50:11 +02:00
2021-10-24 01:47:23 +02:00
```
2021-05-04 00:50:11 +02:00
git clone https://github.com/24eme/signaturepdf.git
2021-10-24 01:47:23 +02:00
```
2021-05-04 00:50:11 +02:00
To run it:
2021-05-04 00:50:11 +02:00
2021-10-24 01:47:23 +02:00
```
2021-10-07 12:36:11 +02:00
php -S localhost:8000 -t public
2021-10-24 01:47:23 +02:00
```
2021-05-04 00:50:11 +02:00
#### PHP Configuration
2021-11-26 00:22:21 +01:00
```
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
2021-11-26 00:22:21 +01:00
```
2022-01-26 15:11:26 +01:00
#### Apache Configuration
2022-01-26 15:11:26 +01:00
```
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
2022-07-18 21:14:57 +02:00
#### Building the image
2022-07-18 21:14:57 +02:00
```bash
docker build -t signaturepdf .
2023-04-21 12:32:55 +02:00
```
2022-07-18 21:14:57 +02:00
#### Running a container
2022-07-18 21:14:57 +02:00
```bash
docker run -d --name=signaturepdf -p 8080:80 signaturepdf
2023-04-21 12:32:55 +02:00
```
2022-07-18 21:14:57 +02:00
[localhost:8080](http://localhost:8080)
#### Configuration
The following variables can be used to configure the deployment:
2022-07-18 21:14:57 +02:00
2023-09-28 13:25:40 +02:00
| 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 |
| `DEFAULT_LANGUAGE` | Default language for the application | en_US.UTF-8 | fr_FR.UTF-8 |
2022-07-18 21:14:57 +02:00
```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
```
2022-07-18 21:14:57 +02:00
2022-07-08 11:38:39 +02:00
### 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.
2022-07-08 11:38:39 +02:00
The main components are:
2023-04-21 12:32:55 +02:00
2022-07-08 11:38:39 +02:00
- php 8 + php-fpm
- Nginx
- pdftk ("manual" installation requiring openjdk8)
2022-07-08 11:38:39 +02:00
- imagick
- potrace
- librsvg
- ghostscript
2022-07-08 11:38:39 +02:00
What the script does:
2023-04-21 12:32:55 +02:00
- Installs dependencies
- Configures php and php-fpm
- Configures Nginx
- Configures the config.ini
- Clones the repo
2022-07-08 11:38:39 +02:00
```
#!/bin/sh
domain='sign.example.com'
2023-04-21 12:32:55 +02:00
apk update
2022-07-08 11:38:39 +02:00
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;
2023-04-21 12:32:55 +02:00
2022-07-08 11:38:39 +02:00
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;
2023-04-21 12:32:55 +02:00
fastcgi_pass 127.0.0.1:9000;
2022-07-08 11:38:39 +02:00
}
}
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
```
2022-07-18 21:14:57 +02:00
## Configuration
2022-04-14 10:56:48 +02:00
### 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:
2023-04-21 12:32:55 +02:00
```
2022-04-01 18:07:20 +02:00
PDF_STORAGE_PATH=/path/to/folder
```
Create this folder:
2023-04-21 12:32:55 +02:00
```
2022-04-01 18:07:20 +02:00
mkdir /path/to/folder
```
The web server should have write permissions on this folder.
For example, for Apache:
2023-04-21 12:32:55 +02:00
```
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
2022-01-28 18:24:01 +01:00
The latest stable version is on the `master` branch. To update, simply fetch the latest changes:
2022-01-28 18:24:01 +01:00
2022-07-18 21:14:57 +02:00
```
git pull -r
```
2022-01-28 18:24:01 +01:00
## 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
```
2021-11-26 00:22:21 +01:00
## Libraries Used
2021-05-04 00:50:11 +02:00
- **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)
2021-10-24 01:47:23 +02:00
For testing:
2021-10-24 01:47:23 +02:00
- **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)
2021-10-24 01:52:34 +02:00
2023-09-19 12:12:28 +02:00
## Contributions
2022-04-27 13:01:28 +02:00
### 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.
2022-04-27 13:01:28 +02:00
Translations might be added on Weblate : https://hosted.weblate.org/projects/signature-pdf/application/
2022-04-27 13:01:28 +02:00
2023-09-19 12:12:28 +02:00
### Contributors
2023-09-19 12:12:28 +02:00
These people are the authors of the code of this software :
2023-09-19 12:12:28 +02:00
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
2023-09-19 12:12:28 +02:00
- 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
2023-09-19 12:12:28 +02:00
The development of the software was primarily done during the working hours of 24ème employees.