Ink On Paper
This "Ink On Paper" allows users to virtually print, sign, and scan a PDF document "the traditional way."
A minimalist Bash script to automate ImageMagick for paperless signing. This tool allows you to "traditionally" sign PDF documents by overlaying a signature image onto a rasterized PDF page, ensuring the result matches a professional scan.
The tool operates in three distinct phases to ensure pixel-perfect accuracy.
- Preview: Convert a PDF page to a high-resolution PNG "Canvas."
- Prepare: Clean your signature (remove background color and resize).
- Sign: Affix the signature to the document and export a flattened, professionally scanned PDF.
This script relies on ImageMagick and Ghostscript. Ensure that they are in your PATH and executable.
- Linux (Ubuntu/Debian):
sudo apt-get install imagemagick ghostscript - macOS:
brew install imagemagick ghostscript - Windows: MSYS2 or Cygwin are your friend. Ensure that both ImageMagick and Ghostscript are installed and you have a Bash environment. Note: You may need to edit your ImageMagick
delegates.xmlto change all instances of "gswin32c" to "gswin64c".
Render the PDF page into a 300 DPI image. Open this image in any viewer (such as Paint, GIMP, or Photoshop) to find the exact pixel coordinates, i.e., start position and size, for your signature. You may also want to date it or make other modifications before signing.
sign_pdf preview document.pdf 0Outputs: preview_page_0.png
Clean a raw photo of your signature. This assumes the signature is "ink on white paper". This step removes "off-white" paper backgrounds from photography or scanning.
sign_pdf prepare-sig raw_scan.jpg signature_clean.png 50% 15%- 50%: Resize the signature (optional).
- 15%: The "fuzz" factor. Increase this if the signature background is shadowy or gray.
Affix the cleaned signature to the document image and convert it back to PDF.
sign_pdf sign preview_page_0.png signature_clean.png final_signed.pdf 1200 2500 jpeg- 1200 / 2500: The X and Y pixel coordinates obtained from your image viewer, measured from the top-left corner of the page.
- jpeg / zip: Use
jpegfor smaller file sizes; usezipfor lossless archival quality.
By converting the PDF to a PNG canvas before signing, we ensure:
- Coordinate Consistency: The pixel measured on the preview is exactly where the signature is affixed.
- Flattening: The signature becomes part of the image layer. This makes it significantly harder for third parties to extract your signature file compared to standard digital PDF annotations.
The script automatically applies a -strip command to all outputs. This removes:
- EXIF data (camera information and GPS coordinates from your signature photo).
- Invalid PNG color profile chunks (bKGD) that often cause errors in PDF viewers.
The script is hardcoded to 300 DPI. This is the standard for high-quality office scanning. An A4 or Letter page at this resolution is approximately 2500–3300 pixels tall.
This project is licensed under the Apache-2.0 License. Feel free to use it in your personal or professional paperless workflows.