Some useful PDF editing (and search) commands
By jeltsch on Thu, 07/28/2011 - 14:44
- Insert pages with interleave:
pdftk A=input_odd_pages.pdf B=input_even_pages.pdf shuffle A B output collated.pdf(from the pdftk package)
- Split an A2-sized PDF into two A3 pages for printing (no overlap):
pdfposter -m A3 -p A2 Periodic-Table_A2.pdf Periodic-Table_2xA3.pdf
- Split an arbitrary-sized PDF into A3 pages for printing at 100% size (= 1), no overlap:
pdfposter -m A3 -s1 Poster.pdf Poster_split_to_A3.pdf
- Reverse page order:
pdftk input.pdf cat end-1 output reversed.pdf(from the pdftk package)
- Reduce PDF filesize:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf Allowed PDFSETTINGS are /screen, /ebook, /printer, /prepress, /default. (from the ghostscript package)
- Convert a color PDF into grayscale:
gs -sOutputFile=output.pdf -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dAutoRotatePages=/None -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH input.pdf (from the ghostscript package)
- Export bitmap images:
pdfimages -j original.pdf extracted (from the xpdf package)
- Convert into a bitmap image:
convert original.pdf converted.png (from the imagemagick package)
- Split into individual 1-page PDF files:
pdftk original.pdf burst (from the pdftk package)
- Merge two or more PDF files:
pdftk original1.pdf original2.pdf cat output merged.pdf (from the pdftk package)
- Delete page 13 from a PDF file:
pdftk original.pdf cat 1-12 14-end output page13deleted.pdf (from the pdftk package>
- Rotate page 5 of the PDF file 90 degrees counterclockwise:
pdftk Figures_LRES.pdf cat 1-4 5L 6-end output Figures_LRES2.pdf (from the pdftk package>
- Assemble a new PDF where each 4 pages from the source files are merged into one landscape page:
pdfjam *.pdf --landscape --nup 2x2 For portrait orientation use the "--no-landscape" option (from the pdfjam package).
- Underlay a PDF with another (background) PDF:
pdftk foreground.pdf background background.pdf output overlay.pdf (from the pdftk package).
- GUI PDF editors: I tried out PDFEdit, but it is too difficult for me. The Master PDF Editor" is not free, but it seems to be much more usable without extensive initialization of the user.
- Encrypt a PDF with both a owner password (to change the file) and a user password (to open the file):
pdftk input.pdf output encrypted.pdf owner_pw PROMPT user_pw PROMPT (from the pdftk package).
- If you need to do a text search through many PDF files in the current directory and all of its subdirectories, you can use pdfgrep:
pdfgrep -r searchterm * (from the pdfgrep package).
- Convert & merge all jpg files in the current directory into one PDF file:
convert *.jpg pictures.pdf
In the recent Ubuntu editions, this batch operation is not allowed due to security risks and you can disable this policy by renaming the configuration file:
/etc/ImageMagick-6$ sudo mv policy.xml policy.xmlout