Short Notes on PDF

From PaskvilWiki
Jump to: navigation, search

Merging PDF Files using GhostScript

To merge several files file1.pdf, file2.pdf, ... into a single output.pdf file, use

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf -dBATCH file1.pdf file2.pdf ...

The -dNOPAUSE simply means that gs won't stop along the way to ask you questions, like "do you want to continue?".

Cutting PDF Files using GhostScript

To get only pages 50-60 of a document, use

gs -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=my_cut_file.pdf -dFirstPage=50 -dLastPage=60 -dBATCH my_file.pdf

Converting to PDF using GhostScript

You can convert vast array of documents into PDF using gs; to convert PostScript to PDF, use

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf -dBATCH

GhostScript actually supports incredible array of formats; to check what all you can work with, just run

echo 'devicenames == ' | gs -q | tr " " "\n" | sort