2

I have 2 files written in Markdown which I used pandoc to convert into pdf. I now need to combine the 2 into one single document(lets say I have many that I need to combine into a single pdf). Is there a way I can do this efficiently from the terminal itself ?

The simplest way I can think of is by cat ing the files into one as such

cat file1.pdf file2.pdf > file3.pdf 

But this does not provide the desired result. It only produces the first file (depending on whether I put file1 or file2).

Is there a general way of combining different files into one single "entity" without messing up the pages. Say I had to compile a number of pdf "chapters" into a pdf "book" ?

First User
  • 189
  • 2
  • 8
  • 2
    Does this answer your question? [Adobe Acrobat: How to batch to combine multiple pdf files?](https://superuser.com/questions/389760/adobe-acrobat-how-to-batch-to-combine-multiple-pdf-files) – user202729 Mar 26 '23 at 11:42
  • This is not a duplicate as OP did not specify Adobe products, and there is a good answer, even if it is not marked as the answer. – music2myear Mar 27 '23 at 01:09

1 Answers1

3

The usual tool is pdftk. This command will take first.pdf and second.pdf, and create a new merged.pdf which is the concatenation of the two source files:

pdftk first.pdf second.pdf cat output merged.pdf
roaima
  • 2,889
  • 1
  • 13
  • 27