Back to all How-tos

"Stamping" one PDF file on another PDF file

“Stamping” refers to a method of layering one PDF over another PDF, via a script in Workflow. This how-to explains when and how to use this method.

When to use it

The stamping method is excellent to very quickly add something to any existing PDF when it is important not to impact the original PDF’s readability (i.e. the ability to extract text from it).
In some Workflow processes, it is inevitable that PDFs get deconstructed and reconstructed. Doing so entails the risk of a loss of information, which could make the text in the resulting PDF unextractable. Although that risk is very minor in Connect, compared to PlanetPress Suite, on rare occasions it might still happen.
To check whether PDF output is still readable, simply copy-paste some of its text from Adobe Acrobat to, say, Notepad. If that works, so will data mapping; if Notepad yields garbled text, the DataMapper won’t be able to read it, either. In that case, ‘stamping’ is a very good alternative.

How to do it

Basically, instead of using a PDF as background in your document, you design your document solely as an overlay, i.e. you only add the design elements that you want to put over the PDF background, and generate a PDF out of this. This could be something as simple as pages with a lonely barcode on them. Then, in Workflow, add a Script task and use the AlambicEdit API to merge each page of the overlay PDF with the original (i.e. the background) PDF.

The following JavaScript code stamps an external PDF on top of the current job file (assuming the latter is also a PDF). This code requires that both PDFs have the same number of pages.

//Get the output from the ALL-in One plugin (is a PDF with a Barcode)
var OverPDFName = Watch.GetJobFileName();
//Get the background PDF
var UnderPDFName = "C:\\back\\BackPDF.PDF";
var OverPDF = Watch.GetPDFEditObject();


Obviously, set the OverPDFName variable to the proper file location.

The same API can also be used to add barcodes and OMRs, a logo, a watermark across all pages, invisible text (white on white) that you can use later to drive a Workflow process, etc.


You can find in the following file a sample Workflow process with all needed resources.

Leave a Reply

Your email address will not be published. Required fields are marked *