I want add text image and images in pre define indesign template.
but when i am doing
frame.contents += "Test";
frame.contents += "\r";
frame.contents += "Again test";
this will removed all contents of template such as empty tables and frames which is placed below to the frame.
is there any way to insert text in frame and other frames behave like anchor frame.
Hi, this question is best asked in the InDesign Scripting Forum.
I guess, one of the forum moderators will move your question over soon.
Back to your question:
You can use the place() method to place an image file to an insertion point.
An insertionPoint is part of the Text class, that stands for formatted text.
What happen with your little snippet is, that you do a type conversion every time you add a string to the value of contents.
And with that you erase all the specialties that contents can hold. E.g. special characters, that stand for particuar table objects and special characters that stand for anchored objects.
You could also add new contents safely to an insertionPoint by assigning a string to its contents property.
Since insertionPoints can be made available as a collection, you could address the last insertion point of your text frame like that:
myTextFrame.insertionPoints[-1].contents = " Test."+"\r";
That's the same as:
myTextFrame.insertionPoints.item(-1).contents = " Test."+"\r";
myTextFrame.insertionPoints.lastItem().contents = " Test."+"\r";
And if there is overset text and you want to insert your contents after the overset text you could reach that last insertion point through the Story object of the text frame:
myTextFrame.parentStory.insertionPoints[-1].contents = " Test."+"\r";
Depending on the version of your InDesign look up DOM documentation:
Compiled by Gregor Fellenz:
Compiled by Jongware: