// text properties var textRuns = { initialAttrs:{ alignment:"right", antiAliasSharpness:192, antiAliasStrength:64, baselineShift:0, bold:false, face:"Arial", fillColor:"#000000", horizontalScale:1, italic:false, leading:1, leadingMode:"percentage", overSample:8, paragraphIndent:0, paragraphSpacingAfter:0, paragraphSpacingBefore:0, rangeKerning:0, size:"12pt", underline:false }, textRuns:[ { changedAttrs:{}, characters:"" } ] }; text_prefix = "Page "; // page number prefix; if empty ("") only numbers will be created alignment = "BR"; // alignment: "T", "B", "L". "R". "TL", "TR", "BL", "BR" (top, bottom, left, right, etc) // padding properties padding_x = 3; // pixels from left or right edge of document padding_y = 3; // pixels from top or bottom edge of document // Operation var dom = fw.getDocumentDOM(); var n = dom.frames.length; var startFrame = dom.currentFrameNum; alignment = alignment.toUpperCase(); switch(alignment){ case "T": case "B": textRuns.initialAttrs.alignment = "center"; default: textRuns.initialAttrs.alignment = (alignment.indexOf("L") != -1) ? "left" : "right"; } // add text to each frame while (n--){ dom.currentFrameNum = n; dom.addNewText({left:0, top:0, right:0, bottom:0}, true); dom.setTextOrientation("horizontal left to right"); dom.setFillEdgeMode("antialias", 0); dom.setTextAntiAliasing("smooth"); dom.setTextAutoKern(true); dom.setTextAutoExpand(true); textRuns.textRuns[0].characters = text_prefix + (n+1); dom.setTextRuns(textRuns); if (alignment.indexOf("L") != -1){ fw.selection[0].rawLeft = dom.left+padding_x; }else if (alignment.indexOf("R") != -1){ fw.selection[0].rawLeft = dom.left+dom.width-fw.selection[0].rawWidth-padding_x; }else{ fw.selection[0].rawLeft = dom.left+dom.width/2-fw.selection[0].rawWidth/2; } if (alignment.indexOf("T") != -1){ fw.selection[0].rawTop = dom.top+padding_y; }else if (alignment.indexOf("B") != -1){ fw.selection[0].rawTop = dom.top+dom.height-fw.selection[0].rawHeight-padding_y; }else{ fw.selection[0].rawTop = dom.top+dom.height/2-fw.selection[0].rawHeight/2; } } // return to frame started script on dom.currentFrameNum = startFrame;