[Tex/LaTex] Simulate a scanned paper


I'm try to move my current paperwork routine towards a paperless workflow (for the “administrative” type of papers, of course… not for serious reading tasks). There is one major annoyance thwarting me: people sometimes require me to print, sign and scan documents. They will not allow me to insert my scanned signature in an electronic file (even converted to PDF). It's for unimportant papers (e.g., not for contracts!), it's a waste of time, but I cannot make them budge.

Thus, I want to design a filter that takes PDF files as input, and gives them a “scanned document” look. What I have thought of so far:

  1. Rasterization at not-so-great resolution. I have a ghostscript-based filter that does it, and I've used it a few times already. But, the documents keeps their “pristine” aspect: white background is still white, etc.

  2. So, I considered getting a “scanned paper” texture from scanning a blank page, and apply it to my document. But: if I put it in front of the content with low opacity, the text might become too blurry; and if I put it behind the content, it works only if content has a fully transparent background (which is not always true for my documents).

  3. Now, I'm thinking TeX/LaTeX would be great tools to do that, but I cannot translate this nice idea into specifics…

So, what would you suggest?

Best Answer

I guess this is a typical "use the right tool for the right task" question and for these kind of transformation, I would look for an ImageMagick solution:

The following is shamelessly taken from the ImageMagick example gallery, where it is described as a filter to simulate a photo copier effect:

convert letter.pdf -colorspace gray \( +clone -blur 0x1 \) +swap -compose divide -composite -linear-stretch 5%x0% as-scanned.pdf


enter image description here


enter image description here

which to me looks pretty scannerish :-)

Fine-Tuning the Result

Lucas suggested to add also a bit of rotation (in the following I added -rotate 1.5 to the convert line), which improves the result even further:

convert letter.pdf -colorspace gray \( +clone -blur 0x1 \) +swap -compose divide -composite -linear-stretch 5%x0% -rotate 1.5 as-scanned.pdf

enter image description here

For a color scan, just leave off the -colorspace gray operator:

convert letter.pdf \( +clone -blur 0x1 \) +swap -compose divide -composite -gamma 0.1 -linear-stretch 5%x0% -rotate 1.5 as-scanned.pdf

color scan

Related Question