From time to time you may be requested to add your “hand written” signature to all pages of a document or contract.
But printing / signing / scanning every pages of a possibly long document is obviously not the best option.
Creating the signature
- Download and install some “handwritten” fonts you like
👉 convert -list font Font: Arista-Signature family: Arista Signature glyphs: /home/yannick/.local/share/fonts/Arista Signature.ttf Font: Autograf-PERSONAL-USE-ONLY family: Autograf PERSONAL USE ONLY glyphs: /home/yannick/.local/share/fonts/Autograf_PersonalUseOnly.ttf
- Create signature
convert command from
👉 convert -background transparent -rotate -10 -fill darkblue -font Arista-Signature -size 300x200 -gravity center 'caption:AB' out.pdf
Creating the A4 page with the signature
PdfJam tool is used for this purpose
The pdfjam package makes available the
pdfjamshell script that provides a simple interface to much of the functionality of the excellent pdfpages package (by Andreas Matthias) for LaTeX
pdfjamscript takes one or more PDF files (and/or JPG/PNG graphics files) as input, and produces one or more PDF files as output. It is useful for joining files together, selecting pages, reducing several source pages onto one output page, etc., etc.
👉 sudo apt-get install texlive-extra-utils 👉 dpkg -L texlive-extra-utils | grep bin | grep jam /usr/bin/pdfjam
- Create a A4 signed page
--paper PAPERSPEC (or simply --PAPERSPEC) Specify a LaTeX paper size, for example '--paper a4paper' or simply '--a4paper' for ISO A4 paper. --scale 0.7 (to scale all input pages to 70% size) --offset '1cm 0.5cm' (to offset all pages -- note the quotes!)
👉 pdfjam --paper 'a4paper' --scale 0.2 --offset '7cm -12cm' signature.pdf
We have a page ready to be “merged” with existing pages of the document to sign.
This Debian Pdf will be our example document to add our signature into.
👉 wget https://www.debian.org/releases/stable/i386/install.pdf.fr 👉 file install.pdf.fr install.pdf.fr: PDF document, version 1.5 👉 mv install.pdf.fr debian.pdf
To “merge” we are using
pdftk - A handy tool for manipulating PDF
👉 sudo apt install pdftk 👉 pdftk debian.pdf stamp signature-pdfjam.pdf output combined.pdf
stamp <stamp PDF filename | - | PROMPT>
This behaves just like the background operation except it overlays the stamp PDF page on top of the input PDF document’s pages. This works best if the stamp PDF page has a transparent background.
The signature is added to all pages of the document.
Apply to only some pages
In case only few specific pages needs to have the signature.
- Extract pages to add signature into
👉 pdftk debian.pdf cat 35 output page35.pdf
- Add signature to those pages
👉 pdftk page35.pdf stamp signature-pdfjam.pdf output signedpage35.pdf
- Assemble non signed, with signed pages
👉 pdftk A=debian.pdf B=signedpage35.pdf cat A1-34 B A36-end output signed-onlypage35.pdf
With the method above, the document will look as clean as it was before, lines can still be selected like into the original document, so recipient will be able to notice it’s not a “real” signature added on a scanned document.
Most people will not care, but in case some recipients care about it, we can add an extra step.
👉 convert -density 130 signedpage35.pdf -rotate 0.33 -attenuate 0.15 +noise Multiplicative -colorspace Gray scanned-page35.pdf
This will make the document “not perfect” with some gray lines on the side and kind blurry like it could be with a scan process.
For large documents this may require to increase
memory limit of
👉 identify -list resource Resource limits: Width: 16KP Height: 16KP List length: 18.446744EP Area: 128MP Memory: 256MiB Map: 512MiB Disk: 1GiB File: 768 Thread: 4 Throttle: 0 Time: unlimited
👉 sudo vi /etc/ImageMagic-6/policy.xml <policy domain="resource" name="memory" value="256MiB"/>