myNewText = "SOME TEXT"
myTextFrame = myPage.textFrames.item(0);
tempframe = myTextFrame.contents;
myTextFrame.contents = myNewText + tempframe ;
But i want to specify the font used,size and color for that text.
myNewText .appliedFont = app.fonts.item("Times New Roman");
myNewText .fontStyle = "Bold";
nothing gets changed and font family already used stays the same.
How can i do that only for the added text and not for the whole content?I dont want to add the text to a new text frame I want to append it to the existing text frame.
And is there a way to specify font size too?
There's a mixup going on here. Let's see if we can sort out some of it
If you just want to add new text to an already existing text frame,
myTextFrame.contents += "Hello";
But if you want the new text to have unique formatting, it's a little
There are two simple ways to do it, I think:
1. Create a temporary text frame, as you have done, and add the text,
and format everything in there. Then move() that formatted text to the
end of myTextFrame and delete the temporary frame:
tempFrame = app.activeDocument.textFrames.add();
tempFrame.contents = "New Text";
tempFrame.paragraphs.appliedFont = app.fonts.itemByName("Times New
Roman"); // etc...
2. The other option, is to add the text directly to your textFrame. But
if you want to format only that text, you have to store where the text
myTextFrame = app.selection;
firstInsertionPoint = myTextFrame.insertionPoints[-1].index;
myTextFrame.contents += "New Text";
myAddedText.appliedFont = app.fonts.itemByName("Trajan Pro"); // etc.
What you've done in your sample script, however, is to try to apply a
it, it won't throw an error either, because in fact you've created a new
property of your string. (myString = "Hello"; myString.appliedFont =
but that's nothing to do with InDesign!)
Europe, Middle East and Africa