Local formatting a paragraph's characters one by one
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Local formatting a paragraph's characters one by one
Tagged: character formatting properties
- This topic has 1 reply, 1 voice, and was last updated 6 years, 11 months ago by Tamás Nagy.
-
AuthorPosts
-
-
April 29, 2017 at 6:23 am #93955Tamás NagyParticipant
Hi friends,
I am trying to copy the character attributes of one paragraph’s characters onto the characters of another paragraph. There may be up to (say) 10 different types of local formatting in the source paragraph. The rules on how to do this are complicated: it’s not simply that character[1] of the destination paragraph should look like the character[1] of the source, and so on with char[2], char[3] etc., the special chars are mixed up, the number of characters and even the language of the two paragraphs are different.
My problem is that I can’t get (or set, btw.) the attributes like this:
myChrProps=myParagraph.characters[i].properties;
because I get error message: Object is invalid.
Okay, I tried this:
myTemp=myParagraph.characters.everyItem().getElements();
myChrProps=myTemp[i].properties;
Te result is the same, error message on the first line.
Well, let's try this:
myTemp=myParagraph; alert(myTemp+"\r"+myTemp.length);
myTemp=myTemp.characters; alert(myTemp+"\r"+myTemp.length);
myTemp=myTemp.everyItem(); alert(myTemp+"\r"+myTemp.length);
myTemp=myTemp.getElements(); alert(myTemp+"\r"+myTemp.length);
myChrprops=myTemp[i].properties;
Aaaaaand victory!!! I could even define a character style with the props I got in response.
BUT the same code without the alerts leads to the error message again.Can someone explain me what's going on?
Tom
-
April 29, 2017 at 6:26 am #93956Tamás NagyParticipant
Sorry, second try:
Hi friends,
I am trying to copy the character attributes of one paragraph’s characters onto the characters of another paragraph. There may be up to (say) 10 different types of local formatting in the source paragraph. The rules on how to do this are complicated: it’s not simply that character[1] of the destination paragraph should look like the character[1] of the source, and so on with char[2], char[3] etc., the special chars are mixed up, the number of characters and even the language of the two paragraphs are different.
My problem is that I can’t get (or set, btw.) the attributes like this:
myChrProps=myParagraph.characters[i].properties;
because I get error message: Object is invalid.
Okay, I tried this:
myTemp=myParagraph.characters.everyItem().getElements();
myChrProps=myTemp[i].properties;
Te result is the same, error message on the first line.
Well, let’s try this:
myTemp=myParagraph; alert(myTemp+"\r"+myTemp.length);
myTemp=myTemp.characters; alert(myTemp+"\r"+myTemp.length);
myTemp=myTemp.everyItem(); alert(myTemp+"\r"+myTemp.length);
myTemp=myTemp.getElements(); alert(myTemp+"\r"+myTemp.length);
myChrprops=myTemp[i].properties;
Aaaaaand victory!!! I could even define a character style with the props I got in response.
BUT the same code without the alerts leads to the error message again.Can someone explain me what’s going on?
Tom
-
-
AuthorPosts
- You must be logged in to reply to this topic.