I have 2 existing PDFs. They could have image, text, tables, etc… How would I overlay 1 on top of the other? I’ve attached 2 PDFs that I am testing with. The output should be 1 PDF. What would be the best way to do this (that accounts for all types of elements on a PDF)?
overlay_hold.pdf (33.2 KB)
base_hold.pdf (56.1 KB)
@Robert343
Can you please share an expected output PDF for our reference so that we can test the scenario in our environment and address it accordingly.
Here is an example of the output generated with abc pdf.
output.pdf (148.1 KB)
@Robert343
Please try using below code snippet in order to achieve your requirements:
var pdfDocument = new Document(dataDir + "base_hold.pdf");
var stamp = new PdfPageStamp(dataDir + "overlay_hold.pdf", 1);
foreach (Page page in pdfDocument.Pages)
page.AddStamp(stamp);
pdfDocument.Save(dataDir + "Result.pdf");
Result.pdf (79.9 KB)
We need all the text elements and images all to be real objects in the document. Here is our code we had started, but we are not sure what other elements are in a PDF and how to add them. We only have code for copying raw text and images.OverlayTest.zip (225.9 KB)
@asad.ali, the results from your AddStamp code looks good actually. Can you explain what it does to the PDF? Does it place raw elements on the PDF page or does it lay an image or something on top of the other?
@Robert343
We are collecting related information in the API and will get back to you shortly.
@Robert343
PdfPageStamp copies the content of the page into the content of a Form X-Object and adds the “Do” operator into the contents of the page where the PageStamp is placed. Therefore, this stamp is not like an ImageStamp: the text from the page that is used for the stamp can be extracted, etc.