Article View: adobe.scripting.indesign
Article #8587Re: Script that can convert character attribs to character stylesheets
From: Martin Fischer*
Date: Wed, 11 Oct 2006 19:27
Date: Wed, 11 Oct 2006 19:27
30 lines
1801 bytes
1801 bytes
The approach of Peter is very well (I like it).
But here is another approach:
Sometimes I don't know, which fonts will arrive in InDesign and I dont't want to customize scripts every time for new documents.
Here is a script that will create a character style based on font name and style of the first character of the selection. The name of the CS is put together of the font name and the style of the first character of the selection.
var myDoc = app.documents[0];
var mySel = app.selection[0].characters[0];
var myFont = mySel.characters[0].appliedFont.fontFamily;
var myStyle = mySel.characters[0].appliedFont.fontStyleName;
try
{
myCStyle = myDoc.characterStyles.add({name:myFont + "-" + myStyle, appliedFont: myFont, fontStyle:myStyle})
}
catch(e)
{
myCStyle = myDoc.characterStyles.item(myFont + "-" + myStyle)
}
app.findPreferences = null; app.changePreferences = null;
var myResults = myDoc.search("", false, false, undefined, {appliedFont:myFont, fontStyle:myStyle},{appliedCharacterStyle:myCStyle})
This script is not as well formed as Peter's is.
But maybe it sometimes will help too.
Martin
Technical Details
Message-ID:
<3bc1cee8.11@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc1cee8.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,9f7c3ecb4b002363 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Martin Fischer*" <martin.fischer@online.de> Newsgroups: adobe.scripting.indesign Subject: Re: Script that can convert character attribs to character stylesheets Message-ID: <3bc1cee8.11@webcrossing.la2eafNXanI> Date: Wed, 11 Oct 2006 12:27:48 -0700 References: <3bc1cee8.-1@webcrossing.la2eafNXanI> Lines: 33 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!news.ecp.fr!news.stben.net!webcrossing