'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 topic 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 it impossible to extract text from the resulting PDF.

Although that risk is very minor in OL 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, the Execute Data Mapping task will be able to read it. Notepad yields garbled text, data mapping will fail. In that case, ‘stamping’ is a very good alternative.

How to do it

Basically, instead of using a PDF as background in your template, you design a template solely as an overlay, i.e. you only add the design elements that you want to put over the PDF background. This could be something as simple as pages with a single barcode on them.
Generate a PDF out of this in a standard OL Connect Print workflow.

Note: Typical OL Connect workflows are described in OL Connect's Online Help; see Workflow processes in OL Connect projects.

Then, again 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).
Note that this code requires that both PDFs have the same number of pages.

Copy
//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();
OverPDF.Open(OverPDFName,false);
OverPDF.MergeWith(UnderPDFName);
OverPDF.Save(true);
OverPDF.Close();

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. (see AlambicEdit API reference).

Resources

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