Search code examples
ubuntupdfpdftk

Merge multiple pdf pages into specific pdf page using pdftk


I have merged.pdf file with 18 pages. I would like to merge into source.pdf file starting from page 46 and get final.pdf using PDFTK

I tried with this command, but it didn't work:

pdftk A=source.pdf B=merged.pdf cat A1-45 B1-18 A64 output final.pdf

Any idea?


Solution

  • Only a little correction of your original proposal is needed:

    pdftk A=source.pdf B=merged.pdf cat A1-45 B A46-end output final.pdf

    You don't have to write "B1-18" to refer to the whole document. You can just use "B" to indicate an entire PDF. BTW, you can also use "end" if you want to refer to the last page, e.g. "B1-end"

    "A64" in your example means "catenate page 64 of source document" but - if I understand it correctly - you want to put those 18 pages inside larger document and you don't want to lose any page of any of those two documents, right?

    Then you need to catenate first 45 pages of the source document (which translates to "A1-45"), then 18 pages of the merged document ("B"), and finally all the pages from page 46 to the end of the source document ("A46-end").