Manipulations on pdf files

From GHER

Revision as of 16:46, 23 January 2013 by Charles (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Basic operations

Split a pdf into multiples files, merge different files, extract a given page... The solution is the Pdftoolkit (pdftk).

Examples

You can find useful examples at http://www.pdflabs.com/docs/pdftk-cli-examples/

  • Split a pdf file into multiple files
pdftk mydoc.pdf burst
  • Create a new document with only selected pages
pdftk A=input.pdf cat A1 A274-275 output output.pdf

Here the new file output.pdf will containe the pages no. 1, 274 and 275 from the original document.


Conversion from color to black and white

When you want to be sure the pdf you have to print has no color. The first solution provides better results.

gs \
-sOutputFile=output.pdf \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-dProcessColorModel=/DeviceGray \
-dCompatibilityLevel=1.4 \
-dAutoRotatePages=/None \
-dNOPAUSE \
-dBATCH \
input.pdf
convert -colorspace GRAY input.pdf output.pdf

Edition / annotations

pdfedit is a free editor.

Adding watermark

Again you can use pdftk:

pdftk in.pdf background back.pdf output out.pdf 

where back.pdf is the file containing the background. If the background of the input pdf is not transparent, you have to instead use:

pdftk in.pdf stamp back.pdf output out.pdf 

More details here: http://www.pdflabs.com/docs/pdftk-man-page/

Decrease size of the file

You can use the tool qpdf, available at http://sourceforge.net/projects/qpdf/

qpdf --linearize input.pdf output.pdf

Source: http://stackoverflow.com/questions/5296667/pdftk-compression-option, where other possibilities are presented.

Personal tools