Convert to Image

http://askubuntu.com/questions/50170/how-to-convert-pdf-to-image/50180

Imagemagick

convert           \
   -verbose       \
   -density 150   \
   -trim          \
    test.pdf      \
   -quality 100   \
   -flatten       \
   -sharpen 0x1.0 \
    24-18.jpg

JBWhitmore

Multipage PDF:

convert -quality 100 -density 600x600 multipage.pdf single%d.jpg

PDFtoPPM

You can use pdftoppm to convert a PDF to a PNG:

pdftoppm input.pdf outputname -png

This will output each page in the PDF using the format outputname-01.png, with 01 being the index of the page.

Converting a single page of the PDF

pdftoppm input.pdf outputname -png -f {page} -singlefile

Change {page} to the page number. It's indexed at 1, so -f 1 would be the first page.

Specifying the converted image's resolution

The default resolution for this command is 150 DPI. Increasing it will result in both a larger file size and more detail.

To increase the resolution of the converted PDF, add the options -rx {resolution} and -ry {resolution}. For example:

pdftoppm input.pdf outputname -png -rx 300 -ry 300

enzotib

PDFImages

pdfimages : pdfimages -j input.pdf output

Anmol Singh Jaggi

DJVU

pdf2djvu -o %1.djvu %1
pdf2djvu -o compiled.djvu compiled.pdf
didjvu

Security

To remove restrictions from pdf (that doesn't have password)

QPDF

qpdf --decrypt OddJobs.pdf OddJobs_out.pdf

The Ghostscript way

gs -sPDFPassword=$PASS -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%stdout% -c .setpdfwrite -f locked.pdf > unlocked.pdf

Burst

http://linuxcommando.blogspot.co.uk/2013/02/splitting-up-is-easy-for-pdf-file.html

http://linuxcommando.blogspot.co.uk/2014/01/how-to-split-up-pdf-files-part-2.html

http://linuxcommando.blogspot.co.uk/2015/03/how-to-merge-or-split-pdf-files-using.html

http://www.linuxscrew.com/2010/06/18/the-easiest-way-to-split-and-merge-pdf-files-in-ubuntu/

PDFtk

pdftk 'Caverns of the Snow Witch (Image Only).pdf' burst

Poppler

Only if the PDF is an image:

pdfimages -j $1a.pdf image

Create PDF

Imagemagick

One PDF

convert *.tif book.pdf
MAGICK_THREAD_LIMIT=1 convert *.tif +adjoin book.pdf
convert *.tif -monitor -page A4 book.pdf

Individual PDFs

find . -name '*.tif' -exec sh -c 'convert -compress jpeg -quality 85 $1 ${1%.png}.pdf' sh {} \;

tiff2pdf

tiffcp -c zip *.tif compiled.tif
tiff2pdf -n -z -o compiled.pdf compiled.tif
rm compiled.tif

Merge PDF

PDFtk

$ pdftk myoldfile.pdf cat 1 2 4 5 output mynewfile.pdf

You can specify page ranges like this:

$ pdftk myoldfile.pdf cat 1-2 4-5 output mynewfile.pdf

pdftk is also capable of merging multiple pdf files into one pdf.

$ pdftk pg_0001.pdf pg_0002.pdf pg_0004.pdf pg_0005.pdf output mynewfile.pdf

That would merge the files corresponding to the first, second, fourth and fifth pages into a single output pdf.

Ghostscript

gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=<output>.pdf <pathtoinputfiles>*.pdf

PDFunite

linux command merge pdf files with numerical sort

$ pdfunite $(ls -v *.pdf) output.pdf

or

$ pdfunite $(ls *.pdf | sort -n) output.pdf

However, note that this does not work when filename contains special character such as whitespace.

In the case you can do the following:

ls -v *.txt | bash -c 'IFS=$'"'"'\n'"'"' read -d "" -ra x;pdfunite "${x[@]}" output.pdf'

Although it seems a little bit complicated, its just combination of

Note that you cannot use xargs since pdfunite requires input pdf's as the middle of arguments. I avoided using readarray since it is not supported in older bash version, but you can use it instead of IFS=.. read -ra .. if you have newer bash.