dynamic PDF watermarking

I’ve to watermark incoming PDFs (put some text on every page), text is from a csv.

I’ve successfully done it in designer using the csv as a datamapper input, placing the text on the master page and creating the PDF output.

But now I’m stuck doing that automatically in workflow, e.g. the input isn’t the csv but the pdf itself:

the csv (every record in one line) is static residing in a specific folder, the input folder should receive the pdf’s. How can I generate the watermark overlays and add them to each page of the input pdf? Output should be the watermarked pdf.

The way to achieve this all depends on a number of points. Can you confirm the below:

  • Does the CSV only contain one line of text (text to be added as watermark)? Or does it contain several lines of text and the workflow should somehow select the correct line of text from the CSV based on a characteristic of the incoming PDF ?

If the watermark itself is static and is the same for all incoming PDFs, why not simply create a 1 PDF page watermark and use the AlambicEdit API to merge the incoming PDFs with the 1 page PDF watermark?

If the watermark text is to be selected dynamically from the CSV based on a charcateristic of the incoming PDF, then first the text needs to be extracted from the CSV (Run Script) as a variable that will be passed to the datamapper to create a dynamic 1 page PDF Watermark using either the ALL In-One or Create Preview PDF plugins. Then use the Alambic API to stamp the newly created PDF watermark to your incoming PDF background.

Can provide examples if you get stuck depending on the actual scenario.

Rod, thx in advance…

the csv contains several lines, so each incoming pdf should be watermarked x-times (according to the number of records in that csv). At the end there should be as many watermarked pdfs as records in the output folder.

Any example greatly apreciated!

Not sure this is clear.

So you are saying that you have a CSV with x lines. The watermark to stamp on the incoming PDF is made of all x lines from the CSV? Is that correct? If so, then you should design your PDF watermark using the CSV and Connect Designer and save it to disk. Let’s call that Watermak.pdf (C:\Resources\Watermark.pdf)

Then use the AlambicEdit API to apply the Watermark.pdf to the incoming PDF

dim myPDF, Watermark, pageindex

Set myPDF = Watch.GetPDFEditObject
Set Watermark = Watch.GetPDFEditObject

myPDF.Open Watch.GetJobFileName, false
Watermark.Open “C:\Resources\Watermark.pdf”, false

For pageindex = 1 to myPDF.Pages.Count
myPDF.Pages.Item(pageindex-1).Merge2 Watermark.Pages.Item(0), 0.0, 0.0, 0.0, 1.0
Next

myPDF.Save False
Watermark.Close

sorry for the complicated expression. no, there’s one csv with x lines.
Every single incoming pdf should be watermarked (each page) with each line in one pdf.

So let’s say the csv is:

Field 1
Bob
Martin
Joe

the incoming pdf (“mypdf.pdf”) should then be stamped with Bob, Martin and Joe, so the output would be:
mypdf_Bob.pdf (watermarked with the name “Bob” on each page),
mypdf_Martin.pdf (watermarked with the name “Martin” on each page).

and so on. So if the csv has 30 lines (records), I’ll get 30 resulting pdfs.

Rod,

nearly solved it using two steps:

  1. creating the watermarks (with x pages from the csv)
  2. looping through the watermark-pdf, merging each page to each page of the input pdf (inner loop).

but: the watermarks aren’t transparent as they should be (when doing that in designer via css opacity it works).

as a workaround I modified the watermarks (the pdfs) assigning transparency to the content (outside of PPs scope), then alambic api merging works.