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.
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 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:
passport.jpeg.img2pdf passport.jpeg -o passport.pdf -S A4 -s 125mm
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.
front.jpeg and back.jpeg.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
You may want to supply all your paperwork in one file. This is easy with cpdf:
cpdf passport.pdf idcard.pdf -o paperwork.pdf
magick passport.jpeg -scale 800x passport-small.jpeg