Indistinct chatter since 2006
Paperwork
April 20, 2023

This post was updated May 2026 to replace Adobe Scan with PerspectiveFix, install img2pdf via Homebrew rather than Docker, and replace pdfjam with cpdf (also via Homebrew, eliminating the use of Docker altogether).

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.

Tools

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

The command-line tools can be installed easily on macOS via Homebrew:

brew install img2pdf cpdf

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 an image of your passport. De-skew it, then 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, de-skew and 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
    cpdf front.pdf back.pdf AND -impose-xy "1 2" -o idcard.pdf
    

Joining it all together

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

cpdf passport.pdf idcard.pdf -o paperwork.pdf

Notes and Troubleshooting

  • 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 2026