PDF Operations

A lot of things done with PDFs are using ghostscript-commands. This page is for other things, or multistep operations.

Shift a PDF sideways

A double-sided PDF that is slightly offset from the edge may need to be shifted one way or other. These commands shift both pages towards the binding by about 3mm:

convert -density 300 "Input PDF.pdf" -quality 100 -fuzz 1% -fill white -draw "color 0,0 floodfill"  "output-PNGs.png"
convert "output-PNGs-0.png" -page -9.44+0 -background none "output-PNGs-0_offset.png
convert "output-PNGs-1.png" -page +9.44+0 -background none "output-PNGs_offset.png
convert "output-PNGs-0_offset.png" "output-PNGs-1_offset.png" -density 300 "Output PDF.pdf"

rem "Shifts the PDF by about 3mm (page 0 shifted left, page 1 shifted right)"

These commands use ImageMagick convert, but GhostScript must be installed for them to work. This is primarily for use in Windows, but can be adapted for other systems.

Reverse a PDF

This command reverses the order of pages in a PDF.

pdftk "in.pdf" cat end-1 output "out.pdf"