# 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?

-
Is your scanner so crappy that people can tell the difference? I'm not sure I could tell the difference with our scanner. Or do people compare your signature and see that it's always the same? If the second case, sign your name a bunch of times, scan each of them and insert them randomly into your fake scans. –  Alan Munn Jan 19 '13 at 20:13
@AlanMunn with a common flatbed scanner and default settings, it's pretty easy to tell the difference between a rasterized page and a scanned page (I did a blind test with some friends): paper texture, scanner color artifacts (variations in color from what is originally pure black), compression artifacts, … –  F'x Jan 19 '13 at 20:51
@F'x, another option is just adding a (deceitful) watermark like "SCANNED 19JAN13 AT 20:13:31". Y'know, since we're lying. Prolly good enough for your bureaucrats. –  commonhare Jan 20 '13 at 0:03
This solution uses an entirely different program, so I'm not making it an actual answer. Distressing Documents: cthulhureborn.wordpress.com/2012/10/12/distressing-documents –  BESW Jan 20 '13 at 2:44

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


Thereby

becomes

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


For a color scan, just leave of 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


-
I would rotate it by one or two degrees as well -rotate 2 –  Lucas Jan 20 '13 at 5:40
@Lucas: Great idea, see edited answer. –  Daniel Jan 20 '13 at 8:50
This is both wonderful and sad at the same time. –  Alan Munn Jan 22 '13 at 2:28
This is brilliant! –  nnunes Jan 22 '13 at 16:45
You can add a coffee stain tex.stackexchange.com/questions/67656/… –  alfC May 6 '13 at 21:55

To get a scanned paper texture, you could just add random noise in the foreground. For example, here is a ConTeXt solution. The randomnoise overlay draws 1000 points of 0.2ex radius, scattered randomly, shifted randomly, and with a random gray tone.

\startuseMPgraphic {randomnoise}
newnumeric n;     n = 1000 ;
newpair middle;   middle = (0.5*OverlayWidth, 0.5*OverlayHeight);
newpath scatter;  scatter = fullcircle scaled 0.2ExHeight;

for i = 0 upto n :
fill (scatter randomized 0.1ExHeight) shifted (middle randomized (OverlayWidth, OverlayHeight))
withcolor (0.2 randomized 0.2)*white;
endfor

setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\defineoverlay[randomnoise][\useMPgraphic{randomnoise}]

\setupbackgrounds[page][background={foreground,randomnoise}]

\setuppapersize[A6]

\starttext

\subject {Simulating a scanned paper}
\input ward

\externalfigure[cow][width=2cm]

\stoptext


which gives

You can play around with the size of the dot, and the number of dots to simulate scanners of different quality.

For example, this is what you get with n=10000 and scaled 0.2ExHeight

and this is what you get with n=10000 and scaled 0.05ExHeight

-
This doesn't look like scanned paper at all. This looks like random points were added on the document. –  Antoine Lecaille Jan 20 '13 at 12:55
Aditya, your scanner might need cleaning. –  lodhb Jan 20 '13 at 13:59

Reviving this thread to share an action I made in Photoshop--it offers options to create a high-contrast BW scan or grayscale scan of slightly higher quality. I haven't made one for color scans, yet.

https://dl.dropboxusercontent.com/u/74453/Paper%20scan%20effects.atn

To load action (Instructions written for Photoshop CS5 for Windows):

Open Photoshop and make sure Actions are visible in your workspace (from Window menu) On the Actions window in your side panel, click on the little menu icon on the top-right Select 'Load Actions' from the list Navigate to the .atn file on your computer and click Load.

Next, open a PDF or image file of a document into Photoshop (Right-click, Open With...) Select the action you want to try and then click on the Play icon

Adjust as needed, then save your file as a PDF (or you could Print to PDF). If you save it as a Photoshop PDF, use a very low quality setting. You can adjust the compression to yield more artifacts when setting the JPG quality to low.

I've compared this side by side with actual scans and it's pretty dead on.

Hope this helps.

-
***Of course, you would need to use Photoshop to use this, I failed to mention! –  user71146 Jan 25 at 9:41
This is brilliant and deserves way more upvotes. Much better result than Imagemagick, in my opinion! –  Doggie52 Apr 5 at 10:14