Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

overlay one pdf or ps file on top of another

Tags:

pdf

postscript

I have two pdf or postscript files (I can work with either one). What I want to do is merge each page on top of the other so that page1 of document A will be combined with page 1 of document B to produce page 1 of the output document. This isn't something I necessarily want need to do programatically, although that would be helpful.

Any ideas?

like image 483
JohnnyLambada Avatar asked Feb 01 '09 22:02

JohnnyLambada


People also ask

Can you Overlay 2 PDFs?

You can do this with pdf files using the command line tool pdftk using the stamp or background option. This will only work with a one-page background file. If you have multiple pages, you can use the multibackground command instead.

How do I make a PDF overlay?

In the Power PDF Properties dialog box, click the PDF Settings tab. In the Destination section, select Overlay with existing file in the If File Exists selection box. Check that Query the file name is selected in the Naming Method selection box. Click the Overlay button.


2 Answers

You can do this with pdf files using the command line tool pdftk using the stamp or background option.

e.g.

$ pdftk file1.pdf background file2.pdf output combinedfile.pdf 

This will only work with a one-page background file. If you have multiple pages, you can use the multibackground command instead.

like image 159
bmb Avatar answered Sep 24 '22 21:09

bmb


I had success solving this problem (PDF only and Python) by using pyPdf, specifically the mergePage operation.

From the docs:

# add page 4 from input1, but first add a watermark from another pdf: page4 = input1.getPage(3) watermark = PdfFileReader(file("watermark.pdf", "rb")) page4.mergePage(watermark.getPage(0)) 

Should be enough to get the idea.

like image 26
pi. Avatar answered Sep 20 '22 21:09

pi.