top | item 30024165

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

939 points| tercio | 4 years ago |gitlab.com | reply

390 comments

order
[+] cpitman|4 years ago|reply
I had another version of this at the DMV. They needed to see bills that offered proof of my residence (ie power/water/etc). Turns out they wanted them to be mailed to you, which wasn't going to work because I do paperless billing for everything. So I printed them out and tri-folded them as if it had been in an envelope.

People in front of me in line got turned away for using printed bills, but mine worked just fine.

[+] tombert|4 years ago|reply
I really hate dealing with my printer (or any printer for that matter), so I make pretty liberal use of my drawing tablet at this point. I import the PDF into Krita, use the ballpoint pen brush, and sign. I export to PNG, then use an imagemagick script to rotate it some random number between 1-3 degrees, and add noise onto it to look like a scan.

It's a pain, but it's still less annoying than dealing with a printer.

[+] xur17|4 years ago|reply
I have a png of my signature, and I just paste it into the pdf, and submit that. Haven't run into a complaint yet, and I don't have to print anything.
[+] seb1204|4 years ago|reply
Years ago I user a good blue Ball pen and signed in a blank paper. I scanned this in high resolution, cropped, fattened the lines, removed background and saved it as a transparent PNG. I added this PNG as a stamp to my favourite PDF software and have signed many many documents. The thing to remember is to flatten comments after I stamped my signature onto the document.
[+] tootie|4 years ago|reply
You can actually sign a PDF this way just using Preview on MacOS.
[+] jjcm|4 years ago|reply
I use Figma quite a bit for this. Just make my signature a component and drop it in where I need it.

Used to use Photoshop where I just made my signature a custom brush.

Disclaimer: I work for Figma.

[+] mrb|4 years ago|reply
I have a shell script based on ImageMagick that gives a PDF a "scanner" look. I typically open the PDF in Master PDF Editor to insert an image of my signature, then pass it through my script. When I do need it, it's rare, but it becomes a real life saver. It has avoided me the need to print and scan 100+ pages for a mortgage company, some stock brokers and banks. Key points of the script:

"+noise Random -fill white -colorize 95%" to add some noise to the image

"-distort ScaleRotateTranslate '$x,$y $angle'" to randomly shift horizontally and vertically the document, and randomly rotate it slightly

"-density 150" for a low-ish resolution so it better hides the fact the PDF wasn't really scanned

"-colorspace Gray" to make it black & white

"-quality 60" to increase JPG compression and somewhat reduce picture quality

  #!/bin/bash
  # Make a pdf look like it was scanned.
 
  if [ $# -ne 2 ]; then
      echo "Usage: $0 input output" >&2
      exit 1
  fi
  tmp="$1".scanner-look.tmp
  mkdir "$tmp" &&
  # without -flatten some PDF convert to a JPG with a black background
  convert -density 150 "$1" -colorspace Gray -quality 60 -flatten "$tmp"/p_in.jpg &&
  : || exit 1
  # each page is randomly shifted in the X and Y plane.
  # units seem to depend on angle of rotation in ScaleRotateTranslate?
  offset() { echo $(($RANDOM % 1000)); }
  for f in "$tmp"/p_in*jpg; do
      # each page is randomly rotated by [-0.5 .. 0.5[ degrees
      angle=$(python -c 'import random; print(random.random()-0.5)')
      x=$(offset)
      y=$(offset)
      convert "$f" \
        -blur 0x0.5 \
          -distort ScaleRotateTranslate "$x,$y $angle" +repage \
        \( +clone +noise Random -fill white -colorize 95% \) \
        -compose darken \
        -composite \
        ${f/p_in/p_out}.pdf || exit 1
  done
  # concatenate all the pages to one PDF
  # use "ls -v" to order files correctly (p_out-X.jpg where X is 0 1 2 ... 9 10 11 ...)
  pdftk $(ls -v "$tmp"/p_out*.pdf) cat output "$2" &&
  rm -rf "$tmp"
[+] distances|4 years ago|reply
I have a script for the same purpose too, but I prefer a black-and-white 1-bit palette for that fax look. Here's my version -- note that it uses graphicsmagick, img2pdf, optipng, and pdftk. Also enforces A4 so some of you may want to change that. For fun it's doing the page processing in parallel to speed up a bit with large documents.

    #!/bin/bash

    # Adds a bad scanning effect to PDF files.

    if [ $# -ne 2 ]; then
      echo 1>&2 "Usage: $0 input.pdf output.pdf"
      exit 3
    fi

    convertPage() {
      # PDF filename in first parameter, page in second
      file=$1
      page=$(($2-1))
      png=$(printf "pdf2scan-page-%05d.png" $2)

      # Convert PDF page to black and white PNG
      gm convert -density 300 "$file"[$page] +dither -rotate 0.35 +noise Gaussian -type bilevel -fill white -fuzz 90% -colors 2 $png

      # Optimize PNG
      optipng -silent $png
    }

    export -f convertPage

    # Read number of pages
    pages=$(pdftk "$1" dump_data | grep NumberOfPages | sed 's/[^0-9]*//')

    # Loop through pages and convert in parallel
    for i in $(seq 1 $pages)
    do
      echo "$1":::$i
    done | parallel --eta --colsep ':::' convertPage {1} {2}

    # Create PDF from PNGs
    img2pdf -o "$2" --producer "" --pagesize A4 pdf2scan-page-*.png

    # Remove temporary files
    rm pdf2scan-page*
For a cleaner 1-bit look without noise and rotation, use "gm convert -density 300 "$file"[$page] +dither -colors 2 -type bilevel -fill white -fuzz 40% $png".
[+] hyperdimension|4 years ago|reply
Kind-of-related: I'm wondering if anyone can help me find a website I found a long time ago (probably through StumbleUpon, if that tells you anything about how long ago)

It was a "government document simulator." What you would do is upload a nicely scanned document, and it'd give you back a mis-alighed, crappy quality "scan" of that document, with random blotches and other visual noise. You know, like regular government/FOIA-received documents.

I feel like this is halfway there, if not more (so thank you!), but that website was so authentic.

I don't know if it's even around, but it made me giggle, and I'd like to find it again. If not--great startup idea!

[+] ca7|4 years ago|reply
Thanks for this!

"-flatten" results in all PDF pages being rendered into a 1 page PDF output. If "-flatten" is removed, I get a multi-page PDF output as expected. Thoughts?

EDIT: "-flatten" does what it is supposed to. Delete if operating on multipage PDF.

[+] jsiepkes|4 years ago|reply
Nice tool!

Though personally I just use something like Xournal++ to edit the PDF (add text, add a signature image, etc.) and then use the following command to "fake scan it":

convert -density 150 input.pdf -colorspace gray -blur 0x0.1 -sharpen 0x5.0 -level 10%,90% -rotate -0.5 -sharpen 0x1.2 output-scanned.pdf

[+] seqizz|4 years ago|reply
I don't even bother with making it look like scanned. Just adding a png signature with Xournal and that's it. Mostly government requests it so they never cared enough to complain.
[+] Fiahil|4 years ago|reply
> 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.

I hear you, fellow Frenchman !

[+] jve|4 years ago|reply
Don't know about different Jurisdictions, but from where I am - this has NO legal binding whatsoever. We have those gov issued digital, invisible signatures for that, embedded in our personal ID card. Whatever is properly signed with digital signature, the printed out page bears no legal force.

Anyway, businesses still like to do it this way ("Signing" pdf by applying some pixels). I wonder if it is just an inconvenience to overcome both for businesses and consumers that just write this off and don't bother that it is such a weak binding. It is like some dirty workaround/hack to put those silly signatures on digital documents to get stuff done.

[+] grst|4 years ago|reply
Having moved from Germany to Austria I was pleasantly surprised that they have a functional national ID system that you can use to sign PDFs with a qualified electronic signature. Within Austria, they have been accepted everywhere so far.

https://www.handy-signatur.at/hs2/#!sign/single

When I tried sending such a document to a German insurance company, they refused to accept it. I ended up faxing the document :/

[+] 7steps2much|4 years ago|reply
Usually sending them the following helps them be less stubborn:

> Gemäß Artikel 25 eIDAS-Verordnung hat eine qualifizierte elektronische Signatur die gleiche Rechtswirkung wie eine handschriftliche Unterschriftund wird in allen Mitgliedstaaten anerkannt.

Doesn't work always, but the times it doesn't I usually find a competitor that does prove to be more cooperative pretty easily!

[+] spapas82|4 years ago|reply
For a project that you can use to actually sign (electronically of course) a PDF file or verify that a PDF file has a proper signature take a look a this:

https://github.com/spapas/pdf-sign-check

It uses org.bouncycastle and apache pdfbox and is completely open source. I'd be happy to help anybody that wants to use it in his organization!

We use it sucessfully in my organization (public sector in Greece) for some years; notice that to be able to sign you need to have a proper certificate for your organization.

[+] seb1204|4 years ago|reply
Nice, but from my experience people don't know digitally signed PDF. They want paper with wet signatures or looking like wet signatures. On the other end of the scale I have seen pdfs signed with self created certificates or signed by mouse movement.
[+] russelltran|4 years ago|reply
Oh my goodness, I have dealt with a pedantic bureaucrat who rejected my signed PDF and insisted on the hand signature hahaha. So I printed the document out with my digital signature pasted twice, one below the other, and added a couple sharpie smudges to the bottom one before scanning to quietly “insist back” that there’s no difference between my manual and digital one. Regardless, The automaton was satisfied!
[+] halpert|4 years ago|reply
Preview on Mac OS can do this. You hold your signature up to the camera and then it creates an image you can add to any pdf.
[+] gyulai|4 years ago|reply
I think the author of this tool is totally missing the point of the print/sign/scan legal hoop that one sometimes has to jump through. The law sometimes requires certain documents to be "in writing" and there is, unfortunately, a legal tradition tied to this that "in writing" means "physically on paper", which many lawmakers and bureaucrats unfortunately haven't managed to properly transition into the digital age.

However something that is quite a separate matter is the question of whether one needs to actually be in possession of that piece of paper. A scan of an original serves as proof that the original exists. ...and this is usually all that anyone requires for practical intents and purposes.

But: You're not supposed to do print/sign/scan, and then just throw away the original. You're kind of supposed to keep it in case you're ever asked by a court to produce it. The document partially loses its forensic value if no original can be produced.

[+] heydonovan|4 years ago|reply
I hate PDF's with a passion. Not once have I ever wanted to use one. All the pinching and zooming, such a waste of time. I'm giving this a shot next time I need one, the whole scanner thing needs to go. Are we stuck in the 90's?

Just bought another rental and it was an ordeal trying to find a scanner. Tried the college near me, was denied as you have to be a student. The library is closed down apparently. FedEx didn't have one. The one at the Office Depot was broken. I ended up driving 30 miles to a friends house to use theirs, which required driver upgrades since nobody had used it in a year. I don't understand the point of jumping through all these hoops.

I feel the same with credit card signatures, completely useless and has never once helped me with identity theft or fraudulent transactions. Now I just draw a horizontal line or smiley face.

[+] detritus|4 years ago|reply
If you have a basic handle on a GUI Bitmap editor such as Photoshop or GIMP, and you have a hi-resolution phone, you can just take a photo of the sheet as parallel as you can manage and then create a document that is the same dimensions and then use the warp tool to fit the likely skewed photograph to the exact digital document.
[+] maupin|4 years ago|reply
> All the pinching and zooming, such a waste of time.

Sounds like what you really hate are mobile device displays.

[+] ihattendorf|4 years ago|reply
Do you hate PDF's or do you hate scanned documents? How else should we send text or image documents in a portable format, MS Word? Google Docs?
[+] ahoka|4 years ago|reply
Just take a photo next time, you can use Office Lens or Apple Notes.
[+] koliber|4 years ago|reply
Smart phone scanning apps are incredible. I’ve ditched a flatbed years ago and solely rely on my iPhone. It works like magic. The quality is good-to-great, and it fits well with my workflow. Worth the ten bucks or so investment.
[+] wildrhythms|4 years ago|reply
I was told by a convenience store clerk that it's best to simply write "SEE ID" in place of a credit card signature. In the event the card is stolen, or there is some doubt as to its user, perhaps the criminal would be stupid enough to actually show their ID.
[+] space_ghost|4 years ago|reply
Dropbox's mobile app includes a document scanning feature that seems to work well.
[+] upofadown|4 years ago|reply
I recently learned that a cryptographic signing operation on a PDF is more or less bogus due to the complexity of the format. Every once in a while some researchers take a look and find a bunch of new ways to forge such things. I guess the root problem is that you end up signing a whole whack of stuff that you don't see or understand. That isn't ever going to work. I think that in practice you can only sign plain text if you want it to be secure.

So this really isn't any worse than the alternatives, at least for PDFs...

[+] ddavis|4 years ago|reply
Signature_example.pdf in that repository is NSFW.
[+] lionkor|4 years ago|reply
Honest question: As long as you say you signed it, and you say it's your signature, does it matter how real it looks?
[+] candu|4 years ago|reply
IANAL, but this depends on the jurisdiction. In some places (e.g. Ontario, Canada), e-signatures are fine; often this is because the law explicitly says they have the same effect as a "wet" signature. In this case, "looking real" doesn't enter into it.

In others (e.g. Denmark), you don't even need to sign - merely stating your intent to accept a contract, and having a clear record of that intention, is enough. In this case, again, "looking real" is a non-issue; you can even send an email in some cases.

In yet others, you will definitely be asked for a "wet" signature, and a digital signature is not considered legally acceptable. Here looking real could matter; if your signature is obviously non-physical, it may be refused.

This also varies by situation. In some places, banks want to see a wet signature, _and_ will compare it with an existing wet signature they have on file. In this case, it very much matters how real it looks, where "real" means "matches this other real signature". (Does this make sense? Arguably no, but that's the way it currently is.)

[+] aasasd|4 years ago|reply
I had to look it up when doing deals with someone in Japan, and Wikipedia (iirc) told me that specifically in Japan just scribbling over the pdf via the touchpad is not a legal thing—you have to do the paper dance. Judging from the comments here, France also doesn't encourage all-digital laziness.
[+] bachmeier|4 years ago|reply
And that raises the question for those of us that had to sign a bunch of documents when things were locked down: What purpose does the signature serve? It was a constant hassle that wasted a bunch of my time, and it ultimately was not a signature.
[+] tiborsaas|4 years ago|reply
You are right, that it shouldn't make a difference technically.

I think the goal is to minimize the risk of someone rejecting your document because it looks photoshopped.

[+] fallat|4 years ago|reply
My go to these days is just open gimp -> use my tablet pen -> save again to PDF. I've never been questioned.
[+] technothrasher|4 years ago|reply
Yup, I just "sign" in Acrobat Reader using a signature image I scanned a long time ago, which should be pretty obvious to most people what I've done. But nobody ever complains.
[+] newaccount74|4 years ago|reply
If you have a Microsoft Surface you can just open PDFs with Edge, draw on them with the pen, and save them. It's such a nice feature!

Makes me actually like signing things. And it's also wonderful for sending feedback on stuff.

[+] digisign|4 years ago|reply
I use gimp for this. One layer the imported pdf, the next with my scanned signature from ... 1998? Position, scale to 1024 or so, export grayscale jpg with enough compression to create artifacts, done. The poorer quality the better, tends to make it seem more "legitimate."
[+] RealityVoid|4 years ago|reply
I think I have witnessed the apogee of bureaucratic obsessions with printing and signing. I sent an email to what is similar to the IRS in my country and they answered by typing up the answer, printing it, signing and stamping it, scanning it and attaching it to the reply in my email.
[+] baxtr|4 years ago|reply
What's the thing with the Penises in the readme and example pdf? Is this a joke?
[+] amelius|4 years ago|reply
I still miss a coffee stain.
[+] pydry|4 years ago|reply
it could use a --coffee-stain