Thursday, September 23, 2010

How to merge pdf files into one from command line

Put all the pdf files into a directory
I named them as ch00.pdf, ch01.pdf, etc.
Run on linux command(mac, cygwin, you need Ghostscript installed):
  gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf *.pdf

This method preserves the table of contents of each pdf file

2 comments:

  1. Another good option that I find often generates smaller PDFs is to use the LaTeX package pdfpages. For example, just run the following through pdflatex:


    \documentclass{article}
    \usepackage{pdfpages}
    \begin{document}

    \includepdf[pages=-]{ch00}
    \includepdf[pages=-]{ch01}
    \includepdf[pages=-]{ch03}

    \end{document}


    This approach will let you exclude certain pages, move pages around, etc., and even let you generate a new TOC as you wish. If you have LaTeX installed, you probably already have this package.

    ReplyDelete

Subscribe via email

Enter your email address:

Delivered by FeedBurner

Followers

Blog Archive

google analytics