pdftoppm: Convert PDF Pages to Images
pdftoppm -png -r 150 in.pdf page renders each PDF page to page-1.png, page-2.png, and so on at 150 DPI.
pdftoppm from poppler is the safe, fast way to rasterize PDF pages in CI, avoiding ImageMagick's disabled PDF policy entirely. The DPI and page-range flags control the output.
What it does
pdftoppm uses poppler to render each selected page of a PDF to a raster image. The output format is chosen by flag (-png, -jpeg, default PPM); -r sets resolution; -f/-l pick a page range; the last argument is the output filename prefix (poppler appends -NN).
Common usage
# all pages to PNG at 150 DPI
pdftoppm -png -r 150 in.pdf page
# only the first page (a thumbnail)
pdftoppm -png -r 96 -f 1 -l 1 in.pdf thumb
# render to a single image without the -NN suffix
pdftoppm -png -singlefile -r 150 -f 2 in.pdf page2Options
| Flag | What it does |
|---|---|
| -png / -jpeg | Output format (default is PPM) |
| -r <dpi> | Render resolution (default 150) |
| -f <n> / -l <n> | First / last page to render |
| -singlefile | One page, no -NN suffix on the name |
| -scale-to <px> | Scale longest side to this pixel size |
| -upw <pw> | User password for an encrypted PDF |
In CI
Prefer pdftoppm over ImageMagick for PDF rasterization: it does not hit the policy.xml block and is faster. Note the output naming: pdftoppm in.pdf page produces page-1.png, page-2.png; use -singlefile when you want one fixed name. Pick a DPI that balances clarity and artifact size.
Common errors in CI
"pdftoppm: command not found" means poppler is not installed; apt-get install -y poppler-utils (Debian/Ubuntu) or brew install poppler. "Command Line Error: Incorrect password" means the PDF is encrypted; pass -upw. "Syntax Error: Document stream is empty" or "May not be a PDF file" means a corrupt or non-PDF input. Zero output files usually means the -f/-l range excluded every page.