how do i combine 2 pdf documents into 1 in the terminal?


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” ?