Javascript watermark which uses list of inputted names to batch watermark a file
Hi there, and thanks in advance for any advice.
I've written a simple script to ask the user for a name, watermark files with this input, and then save the file with the same input added to the filename.
As part of my job, it would be even more useful if I could input a list of names and batch watermark them at the same time.
My script so far is below. I have python and html/css experience, so I know vaguely how to do this: set the WaterName variable from the top of the list, run the watermark and saveAs commnads, then go back to line 2 of the list and repeat until there are no more names left.
But I'm new to Javascript in Acrobat and would really appreciate any tips.
Thanks,
Ben
// Ask user for Name
var dialogTitle = "Enter Name";
var WaterName = app.response("Watermark Text",
dialogTitle);
// Add watermark
event.target.addWatermarkFromText({
cText: WaterName,
nTextAlign:app.constants.align.center,
cFont: "Arial",
nScale: -1,
nRotation: 45,
nOpacity: 0.06
});
// Build File Name addition from Name
var cExt = (" - " + WaterName + ".pdf");
//Add the extension to the end of the file name
var cDstName = event.target.documentFileName.replace(/\.pdf$/,cExt);
// Save the file
event.target.saveAs(cDstName);
