Article View: adobe.scripting.indesign
Article #9370Re: [JS CS2] How can I select a piece text and change a property
From: Erik_Bruinsma
Date: Tue, 22 Aug 2006 15:13
Date: Tue, 22 Aug 2006 15:13
42 lines
1988 bytes
1988 bytes
Thank you Cari,
I got it working using your example, but I still would have liked to be able to paste a tagged string into a text contents. Because this way I first paste the whole string, and then start looking afterwards for the bits that need to be bold.
Is there a way to create a selection by giving the positions within the story or the text.
Greetz,
Erik
ps. here is the resulting code, might be usefull for others:
function HandleBold(pi_doc, pi_text)
{
try
{
// get font name
var myCharacterStyle = pi_text.appliedFont.fontFamily + " BOLD";
// find character style
for ( var i = 0; i < pi_doc.characterStyles.length; i++) { if (pi_doc.characterStyles[i].name == myCharacterStyle) styleFound = true; }
if (!styleFound)
{
// error message
....
}
do //while strong tags are found or more than 100 loops
{
startTagStart = pi_text.contents.indexOf("");
endTagEnd = pi_text.contents.indexOf("", startTagStart) + 9;
taggedText = pi_text.contents.substring(startTagStart , endTagEnd);
unTaggedText = pi_text.contents.substring(startTagStart + 8, endTagEnd -9);
var doFindChange = pi_text.search(taggedText, false, true, unTaggedText, undefined, {appliedCharacterStyle:myCharacterStyle});
loopCount++
} while (pi_text.contents.indexOf("", startTagStart) != -1 || loopCount > 99)
}
catch (ex)
{
.....
}
} // HandleBold
Technical Details
Message-ID:
<3bc14b71.2@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc14b71.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,a75ff663f7b720a3 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Erik_Bruinsma@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: [JS CS2] How can I select a piece text and change a property Message-ID: <3bc14b71.2@webcrossing.la2eafNXanI> Date: Tue, 22 Aug 2006 08:13:18 -0700 References: <3bc14b71.-1@webcrossing.la2eafNXanI> Lines: 53 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!news.ecp.fr!news.stben.net!webcrossing