For bureaucratic reasons, a colleague of mine had to print, sign, scan and send by email a high number of pages. To save trees, ink, time, and to stick it to the bureaucrats, I wrote this script.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Edouard Klein 3ff24f0cea Thank you 4 months ago
Dockerfile Update dockerfile deps and add usage instructions 4 months ago
LICENSE Add LICENSE 3 years ago
Makefile Add guix packaging 4 months ago
README.org Thank you 4 months ago
Signature_example.pdf Initial code commit 3 years ago
Signature_guide.pdf Clean up the signature guide file and signature division script 4 months ago
Signature_guide.xcf Clean up the signature guide file and signature division script 4 months ago
VERSION Add guix packaging 4 months ago
document.pdf Add guix packaging 4 months ago
falsicoord.py chmod +x falsicoord 4 months ago
falsiscan.png Initial code commit 3 years ago
falsisign.sh Fix whiting out of color signatures on some documents 4 months ago
guix.scm Add a GUI to choose where to place the signature 4 months ago
signdiv.sh Clean up the signature guide file and signature division script 4 months ago
test.sh Add guix packaging 4 months ago

README.org

FalsiScan: Make it look like a PDF has been hand signed and scanned

For bureaucratic reasons, a colleague of mine had to print, sign, scan and send by email a high number of pages. To save trees, ink, time, and to stick it to the bureaucrats, I wrote this script.

/mal/Falsisign/src/branch/master/falsiscan.png

Installation

⚠ You may need to tweak ImageMagick's default security policy by adding

 <policy domain="coder" rights="read | write" pattern="PDF" />

just before </policymap> in /etc/ImageMagick-7/policy.xml, as recommended in https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion

Binary

Get the latest Linux binary:

wget https://dump.rdklein.fr/falsisign.tar.gz

unpack it at the root of your disk with

cd / && sudo tar xvzf /path/to/falsisign.tar.gz

It will link the falsisign and signdiv exe in /opt/bin/, which the scripts then expect to be in your path:

echo 'export PATH=$PATH:/opt/bin' >> ~/.bash_profile  # or whatever the profile of your shell is

The executable file and all its dependencies will be in /gnu/store/, you can safely remove this directory and the /opt/bin/* links in order to safely uninstall falsisign.

Nix

Gabriel Volpe (@gvolpe) was kind enough to package falsisign for Nix: https://github.com/gvolpe/falsisign.nix

From source

Install guix

Clone this repo:

git clone https://gitlab.com/edouardklein/falsisign.git

cd into it and activate a guix shell where all the dependencies will be met:

guix shell

Docker

Михаил Полыковский was kind enough to provide a DockerFile, you can now clone this repository and run

docker build -t falsisign .

to build the container, then use docker run to falsisign documents.

Manual installation

Please install the following dependencies:

Clone this repo

git clone https://gitlab.com/edouardklein/falsisign.git

Usage

Create a signature sample

  • Print the /mal/Falsisign/src/branch/master/Signature_guide.pdf, preferably on A4 paper,
  • sign in each of the full sized box (this will give 27 different signatures),
  • scan the resulting paper and save it as a pdf (called e.g. signatures.pdf),
  • run ./signdiv.sh -d signatures.pdf (run ./signdiv.sh -h to see offset and margin options, which will help you remove the red guide lines from your signatures),
  • check in signatures that you have 27 png files correctly cropped. You can manually edit the .png files to your liking.

You can maintain multiple signature directories, or run the above again if you want more than 27 signatures.

False-sign and False-scan a document

  • Get the PDF the bureaucrats want you to print, sign and scan (e.g. document.pdf),
  • run ./falsisign.sh -d document.pdf -s signatures -x 1000 -y 2500 -o document-scanned.pdf:

    • The first argument is the document you need to sign/scan
    • The second argument is the directory with all your different signatures
    • The next two arguments are the X and Y coordinates of where your signature will be. The page dimension is 3560x4752.
    • The last argument is the output file name.

You can also initial and sign a document, and choose the pages where to sign and initial (don't forget to quote the page numbers!). The full usage string is:

Falsisign.

Usage:
    falsisign -d <input_pdf> -x <X> -y <Y> [-p <pages>] -s <sign_dir> [-S <scale>] [-c] [-i <init_dir> -z <Z> -t <T> [-q <pages>]] [-r <density>] -o <output_pdf>

Options:
    -d <input_pdf>   The PDF document you want to sign
    -x <X>           The horizontal position in pixels of where the signature will be
    -y <Y>           The vertical position in pixels of where the signature will be
    -p <pages>       Optional space-separated list of pages to sign, e.g. '2 4 10'
                     Defaults to all or only the last if -i is specified
    -s <sign_dir>    Directory where the signatures will be randomly chosen
    -S <scale>       Scaling of the randomly chosen signature in percentage
    -c               Make a clean scan (disable noise and rotation)
    -i <init_dir>    Optional directory where the initials will be randomly chosen
    -z <Z>           Optional horizontal position in pixels of the initials
    -t <T>           Optional vertical position in pixels of the initials
    -q <pages>       Optional space-separated list of pages to initial
                     Defaults to all but the last
    -r <density>     Specify the dpi to use in intermediate steps
    -a <angle>  Specify the rotation (in degrees) to use for all pages
    -o <output_pdf>  The output file name

Finding the coordinates for the signature and initials

Finding the coordinates in pixels where the signature and initials will be is a bit of a pain. One must know that the pages are normalized to a size of 2480x3508, and do a cross-multiplication.

To ease the process, run the falsicoord.py utility, you will see a gray canvas that has the same shape as a portrait A4 page. When you click on it, the window will close and on the standard output will be printed the -x and -y options with the correct values in pixel. You can then copy paste those values in your call to falsisign.sh.

TODO Integrate falsicoord in falsisign.sh and display it for each page, with the page as the canvas background

Thanks

Thank you to all those to reported issues and contributed patches, in particular:

  • Михаил Полыковский
  • Anthony Scemama
  • Gabriel Volpe
  • bocekm
  • Francesco Frassinelli's
  • FalcoSuessgott
  • Karsten Dambekalns
  • Barak A. Pearlmutter