Copy link to clipboard
Copied
I am using Action Wizard to insert blank pages on odd page documents. In the past i used a script that found a file path to a document that says "this page is intentionally left blank", but i would like to build a script that adds a watermark to the new blank page that says the same thing. Below are the two scripts i found but i am unsure how to make them work together. I am new to javascript and im not sure if this is even possible or if im doing everything the hard way. Thanks for the help
Script 1:
if (this.numPages % 2) {
this.newPage();
}
Script 2:
this.addWatermarkFromText({
cText: "This\n\nPage\n\n\n\nIs\n\nIntentionally\n\nLeft\n\nBlank",
nTextAlign:app.constants.align.center,
cFont: "Helvetica-Bold",
nFontSize:36,
aColor: color.red,
nStart: this.pageNum,
nOpacity: 0.5
});
Try this code in the JavaScript console and then add it to an Action and be sure to save the file at the end of the action.
if (this.numPages % 2) {
this.newPage();
//
this.addWatermarkFromText({
cText: "This\n\nPage\n\nIs\n\nIntentionally\n\nLeft\n\nBlank",
nTextAlign:app.constants.align.center,
cFont: "Helvetica-Bold",
nFontSize:36,
aColor: color.red,
nStart: this.numPages - 1,
nOpacity: 0.5
});
} // end if odd number of pages;
Copy link to clipboard
Copied
Have you tried to open a PDF document and run the scripts?
Have you looked at the Acrobat JavaScript API Reference for the newPage and addWaterMarkFromFile?
By default the newPage will be inserted at the end of the PDF but the viewed or focused page will the first page. The watermark can be applied to any page or a range of pages. Your script specifies the currently focused page, so you have to change this to specify the last page. You would also need to include adding the watermark to the block of code within the if statement for the odd number of pages or it will add the watermark to the last page of PDFs with an even number of pages.
Copy link to clipboard
Copied
Thanks that all makes sense and i see the issues. Just having trouble writing it together.
Copy link to clipboard
Copied
Try this code in the JavaScript console and then add it to an Action and be sure to save the file at the end of the action.
if (this.numPages % 2) {
this.newPage();
//
this.addWatermarkFromText({
cText: "This\n\nPage\n\nIs\n\nIntentionally\n\nLeft\n\nBlank",
nTextAlign:app.constants.align.center,
cFont: "Helvetica-Bold",
nFontSize:36,
aColor: color.red,
nStart: this.numPages - 1,
nOpacity: 0.5
});
} // end if odd number of pages;
Copy link to clipboard
Copied
That works like a charm!! Thanks again for the help