Thread View: adobe.scripting.indesign
7 messages
7 total messages
Started by Bal�zs_Slemmer
Tue, 20 Jan 2009 09:41
[CS3 JS] Add formatted text
Author: Bal�zs_Slemmer
Date: Tue, 20 Jan 2009 09:41
Date: Tue, 20 Jan 2009 09:41
11 lines
1180 bytes
1180 bytes
I'm working on a kind of templating script. This script adds text to the document depending on some input data, so the text can be almost anything. My question is whether there is a convenient way to add formatted text to eg. a given text frame. By formatted I mean a character style applied to it. I can think of a solution like inserting the text, then find it and then apply the character style. Is there a simplier way, by which I mean a built in function or so? Or has someone already written such a function? If not then this work is waiting for me, and when ready I'll share the results :) Thanks in advance for your help! Bal�zs
Re: [CS3 JS] Add formatted text
Author: loic_aigon
Date: Tue, 20 Jan 2009 09:51
Date: Tue, 20 Jan 2009 09:51
4 lines
800 bytes
800 bytes
//Given a textFrame "myTextFrame" & a character style "myCharStyle"
myTextFrame.contents = "Here is my text";
myTextFrame.texts[0].appliedCharacterStyle = app.activeDocument.characterStyles.item("myCharStyle");
Loic
Re: [CS3 JS] Add formatted text
Author: Bal�zs_Slemmer
Date: Tue, 20 Jan 2009 10:36
Date: Tue, 20 Jan 2009 10:36
4 lines
962 bytes
962 bytes
Sorry, I've forgotten to mention, that the text frame into which the text is inserted may contain other texts which shall retain their formatting, and the insertion point where the text is added may also vary. Furthermore the inserted text is usually not a complete paragraph, but added to a paragraph, that's why I use character styles. However thanks for your fast reply! Bal�zs
Re: [CS3 JS] Add formatted text
Author: loic_aigon
Date: Tue, 20 Jan 2009 11:16
Date: Tue, 20 Jan 2009 11:16
7 lines
1087 bytes
1087 bytes
AFAIK, You can do as you suggested : place, find and apply style. However, you may wonder about the process itself. As you create a template, why not thinking about using xml (or tagged text maybe but don't really know nothing about that technique). With xml, you can map a style to a tag. Hence, when you place the xml file, it will throw the text with the style applied at the first place. What I want to say, is that, as you want to automate things, maybe you can consider richer solutions. Loic
Re: [CS3 JS] Add formatted text
Author: Bal�zs_Slemmer
Date: Tue, 20 Jan 2009 18:13
Date: Tue, 20 Jan 2009 18:13
3 lines
920 bytes
920 bytes
I've been around to use XML, but at first glance it seemed difficult... But now I've forced myself to read the help, and made some experiments with this mapping thing, and I think this might be the tool I need, though I have to revise the things I've already done. Thanks for the advice :)
Re: [CS3 JS] Add formatted text
Author: Dirk.Becker
Date: Thu, 22 Jan 2009 10:42
Date: Thu, 22 Jan 2009 10:42
12 lines
1011 bytes
1011 bytes
You can set the properties of your insertion point before inserting the text.
var ip = app.activeDocument.textFrames.item(0).insertionPoints.item(200);
ip.appliedCharacterStyle = "BigRed";
ip.contents = "Hello, world!";
You could even do it in one step:
app.activeDocument.textFrames.item(0).insertionPoints.item(100).properties = { appliedCharacterStyle : "BigRed", contents: "Hello, world!" };
Hth,
Dirk
Re: [CS3 JS] Add formatted text
Author: loic_aigon
Date: Thu, 22 Jan 2009 19:10
Date: Thu, 22 Jan 2009 19:10
1 lines
672 bytes
672 bytes
Nice!
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads