Placing Text And Setting Text-Import Preferences - Adobe 65009333 - InCopy CS4 - PC Manual

Scripting guide: javascript
Hide thumbs Also See for 65009333 - InCopy CS4 - PC:
Table of Contents

Advertisement

Text and Type
var myDocument = app.documents.add();
var myStory = myDocument.stories.item(0);
//Entering special characters directly.
myStory.contents = "Registered trademark: ®\rCopyright: ©\rTrademark: ™\r";
//Entering special characters by their Unicode glyph ID value:
myStory.insertionPoints.item(-1).contents = "Not equal to: \u2260\rSquare root:
\u221A\rParagraph: \u00B6\r";
//Entering InCopy special characters by their enumerations:
myStory.insertionPoints.item(-1).contents = "Automatic page number marker:";
myStory.insertionPoints.item(-1).contents = SpecialCharacters.autoPageNumber;
myStory.insertionPoints.item(-1).contents = "\r";
myStory.insertionPoints.item(-1).contents = "Section symbol:";
myStory.insertionPoints.item(-1).contents = SpecialCharacters.sectionSymbol;
myStory.insertionPoints.item(-1).contents = "\r";
myStory.insertionPoints.item(-1).contents = "En dash:";
myStory.insertionPoints.item(-1).contents = SpecialCharacters.enDash;
myStory.insertionPoints.item(-1).contents = "\r";
The easiest way to find the Unicode ID for a character is to use the Glyphs palette in InCopy (choose Type >
Glyphs to display the palette)—move the cursor over a character in the palette, and InCopy will display its
Unicode value. You can find out more about Unicode by visiting http://www.unicode.org.

Placing text and setting text-import preferences

In addition to entering text strings, you can place text files created with word processors and text editors.
The following script shows you how to place a text file in the default story of a new document (for the
complete script, see PlaceTextFile):
//Places a text file in the default story of a new document.
var myDocument = app.documents.add();
//Parameters for InsertionPoint.place():
//File as File object,
//[ShowingOptions as Boolean = False]
//You'll have to fill in your own file path.
myDocument.stories.item(0).insertionPoints.item(0).place(File("/c/test.txt"), false);
To specify the import options for the specific type of text file you are placing, use the corresponding
import-preferences object. The following script shows how to set text-import preferences (for the
complete script, see TextImportPreferences). Comments in the script show the possible values for each
property.
//Sets the text import filter preferences.
with(app.textImportPreferences){
//Options for characterSet:
//TextImportCharacterSet.ansi
//TextImportCharacterSet.chineseBig5
//TextImportCharacterSet.gb18030
//TextImportCharacterSet.gb2312
//TextImportCharacterSet.ksc5601
//TextImportCharacterSet.macintoshCE
//TextImportCharacterSet.macintoshCyrillic
//TextImportCharacterSet.macintoshGreek
//TextImportCharacterSet.macintoshTurkish
//TextImportCharacterSet.recommendShiftJIS83pv
//TextImportCharacterSet.shiftJIS90ms
//TextImportCharacterSet.shiftJIS90pv
//TextImportCharacterSet.unicode
//TextImportCharacterSet.windowsBaltic
Placing text and setting text-import preferences 27

Advertisement

Table of Contents
loading

This manual is also suitable for:

Incopy cs4

Table of Contents