Copy link to clipboard
Copied
Hi there, and thanks in advance for any advice.
I've written a simple script to watermark files with some text, and then save the file with the same text 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. The list of names could be from a txt file, or even better, inputted by the user when you run the script.
I would then like the script to take a name from each line of such a .txt/input list, run the script watermarking a copy of the file(s), saving it As, then move to the next name in the list.
My script so far is below. I have python and html/css experience, so I know vaguely how to do this: import the list, 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
// Set watermark Name
var WaterName = "A Person";
// 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);
Have something to add?