I need to place a processing instruction at the beginning of every text frame. The instruction itself will contain the page number.
I already worked out a script that will bring the instruction into the document as text, but since that causes page reflow, I would rather it come in as an xml marker. (Just as an aside, the script I mentioned goes from the end of the file to the front, to prevent reflow from being an issue on page breaks.)
What is the best way to do that? I do see how to create the instruction itself: but how do I insert it in place?
Something like this?
var myXMLProcessingInstruction = myRootXMLElement.xmlInstructions.add("blah", "blah");
By Using the below script you can insert tag of start of each and every paragrapgh
var mydoc = app.activeDocument;
var myPg = mydoc.pages;
pages.textFrames.words.insertionPoints.associatedXMLElements.xmlInstruction s.add("pageStart", "TextFrameStart");
A different idea would be to add a label with the instructions to a text frame.
textFrame.label = "Processing instructions here."
Using this you would even see the label's contents in the UI when using the Scriptslabel Panel.
The contents of the label could even be a string of ExtendScript code you could execute by using doScript() or eval().
var instructions = textFrame.label; eval( instructions );