Tuesday, February 14, 2006

Merge PDF files with pdftk

Having some of my manuals/documentations downloaded in several separated pdf files, I wanted to merge them into a single file.

First, I installed pdftk

# apt-get install pdftk

Then, I merged the files into a single file

$ pdftk file1.pdf file2.pdf file3.pdf cat output file123.pdf

When the files to be merged is a lot, I edited the file list in a text editor (or, when I am in a good mood, using ls & awk & sed) then combine it with the script found here

$ cat stdin_pdf.sh
#!/bin/sh
# combine PDFs; pass filenames in on stdin;
# pass output to stdout
read input_filenames
pdftk $input_filenames cat output -

$ cat filelist|./stdin_pdf.sh>mergedfile.pdf


So far, I am satisfied with the result.
However, I am still looking for the method to modify the hyperlink to suit the new file, since the previously scattered files actually hyperlinked to each other. RTFM is in progress :-)

4 comments:

gambas van brewen said...

hayooo, berencana bikin apa nih ?! kok pake ngumpulin semua dokumen.
Bilang2 dong kalo lagi ada proyek ambisius dari King Xlylith.....

gambas van brewen said...

btw, bikin shoutbox di samping donk...
biar kalo pingin komentar singkat ga perlu masuk ke comment

Xlylith said...

Iku ceritane onok manual soko cisco,
tapi tiap chapter dadi sak file.
Ben ringkes, tak gabung dadi siji

smile co said...

does pdftk provide any pdf creating SDK in .NET? I came across pdf merge dll, can someone give me any advice on it?