I have two PDF-files. Both have the same geometry and the same amount of pages. I would like to merge them, such that one file is the background and one file is the foreground. I tried pdftk with the background option:
pdftk bg.pdf background fg.pdf output out.pdf
But pdftk just uses the first page of the bg.pdf as a watermark for all pages. I would like to do it in Java (for example with the iText library) or with a bash command. Any suggestions?
you need to use one of latest build of pdftk
pdftk 1.43 or pdftk 1.44
these builds have a new switch multistamp
http://www.pdflabs.com/docs/pdftk-man-page/#dest-op-multistamp
Same as the stamp operation, but applies each page of the stamp PDF to the corresponding page of the input PDF. If the input PDF has more pages than the stamp PDF, then the final stamp page is repeated across these remaining pages in the input PDF.
otherwise, if you are unable to build pdftk 1.43 or 1.44 from sources, you can use
Pdf Transformer
http://sourceforge.net/projects/pdf-transformer/
java -jar ./pdf-transformer-0.4.0.jar <INPUT_FILE_NAME1> <INPUT_FILE_NAME2> <OUTPUT_FILE_NAME> merge -j
to overlay two pdf files