Creating a watermark script
Hi - I am trying to create a script to add a watermark to all the masterpages of a document. I am trying to create a function which adds a text frame to a layer called watermark. The script is as below
var myDocument=app.activeDocument;
var myPages = app.activeDocument.pages;
var myPage = app.activeDocument.pages.item(0);
var myMasterSpread=myDocument.masterSpreads.everyItem();
var myMasterLength = app.activeDocument.masterSpreads.length;
var myTextFrame;
//Creating a layer called watermark and moving it to the end
try
{
var myLayer=myDocument.layers.add();
myLayer.name = "watermark";
myLayer.move(LocationOptions.AT_END);
}
catch(e_layer)
{
var myLayer=myDocument.layers.item(0);
}
//creating function for watermark
function watermark()
{
myTextFrame=myMasterSpread.textFrames.add({contents: "DRAFT", rotationAngle:45, geometricBounds: [190, 70, 220, 195]});
myTextFrame.itemLayer=myDocument.layers.item("Watermark");
};
watermark ();
This is working fine. But I am unable to change the font, point size of the text frame.
I can add the same if I am not creating a function with the following script but it does not work when I add it to the above function.
It just runs and throws no error.
var myTextObject = myTextFrame.parentStory.paragraphs.item(0);
myTextObject.appliedFont = app.fonts.item("Times New Roman");
myTextObject.pointSize=105;
myTextObject.fillColor=myDocument.colors.add({name:"test", model:ColorModel.process, colorValue:[0, 0, 0, 12]});
Any help would be greatly appreciated
Thank
Rahul Arya