Indistinct chatter since 2006
Paperwork
April 20, 2023

The pandemic's not over - but travel is back. I'll even be in China again soon. I prepared the paperwork for my visa application using just a smartphone and some free software. Without access to an office-style printer/scanner, ID cards and passports were the trickiest to scan.

Here's how I did it. I hope this makes the process a little easier for someone else but please bear in mind I'm a nerd who already had the required software installed.

Tools

I rely on these free tools to wrangle JPEGs and PDFs:

Since both tools have a lot of dependencies, I install and run them in a Docker container which I can throw away afterwards.

Open a terminal, cd to some directory in which you'll place your "scanned" images, and fire up the tools:

docker run -ti -v `pwd`:/work -w /work ubuntu:kinetic
apt update && apt install -y img2pdf texlive-extra-utils

Passports

passport

Passports measure 125mm across; they're covered by ID-3 of ISO/IEC 7810.

We need a one-page PDF containing an image of your passport, at approximately the right size. This is exactly what img2pdf does:

  • You'll need a JPEG of your passport. I use Adobe Scan: it straightens and de-skews and processes backgrounds/textures to look a little like a photocopy. Whatever tool you use, crop as close to the edges as you can.
  • Copy the JPEG to your working directory. Rename it passport.jpeg.
  • Create a single-page, A4 PDF containing this JPEG, centred, at approximately the right dimensions:
    img2pdf passport.jpeg -o passport.pdf -S A4 -s 125mm
    

ID Cards

front

back

ID cards (and credit cards, and many others) measure 85.6mm wide; that's ID-1 of ISO/IEC 7810.

I like to place the back and front of ID cards on the same page. Thanks to a nice property of ISO 216, this is straightforward: combine two single-page A5 landscape PDFs into one A4 single-page PDF.

  • You'll need a JPEG of the front and back of your card. Again, crop as close to the edges as you can. Copy them to your working directory. Rename them front.jpeg and back.jpeg.
  • Create a single-page, A4 PDF containing both JPEGs at approximately the right dimensions:
    img2pdf front.jpeg -o front.pdf -S A5^T -s 85.6mm
    img2pdf back.jpeg -o back.pdf -S A5^T -s 85.6mm
    pdfjam --nup 1x2 front.pdf back.pdf -o idcard.pdf
    

Joining it all together

You may want to supply all your paperwork in one file. This is easy with pdfjam:

pdfjam passport.pdf idcard.pdf -o paperwork.pdf

Notes and Troubleshooting

  • Adobe Scan is only free "as in beer". You'll need to create an Adobe account if you don't already have one. Other apps are available!
  • If you find the PDFs too large (they'll be the size of your images plus a few bytes), scale down the image first. This is straightforward with ImageMagick:
    magick passport.jpeg -scale 800x passport-small.jpeg
    
  • Passports don't tend to lie flat. I found it helpful to place a large clear sheet of plastic or glass on top.
  • Sorry, I don't know of a similarly-elegant way to place the front and back of ID cards onto a single sheet of Letter-sized paper.
© Trevor Johnston 2024