Adobe 65009333 - InCopy CS4 - PC Manual page 31

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

Advertisement

Text and Type
The following example shows how to export a specific range of text. (We omitted the
function from this listing; see the ExportTextRange tutorial script.)
var myDocument = app.documents.add();
var myStory = myDocument.stories.item(0);
//Fill the story with placeholder text.
var myTextFrame = myStory.textContainers[0];
myTextFrame.contents = TextFrameContents.placeholderText;
var myStartCharacter = myStory.paragraphs.item(0).characters.item(0);
var myEndCharacter = myStory.paragraphs.item(1).characters.item(-1);
var myText = myStory.texts.itemByRange(myStartCharacter, myEndCharacter);
//Text exportFile method parameters:
//Format as ExportFormat
//To As File
//[ShowingOptions As Boolean = False]
//
//Format parameter can be:
//ExportFormat.inCopyCSDocument
//ExportFormat.inCopyDocument
//ExportFormat.rtf
//ExportFormat.taggedText
//ExportFormat.textType
//
//Export the text range. You must fill in a valid file path on your system.
myText.exportFile(ExportFormat.textType, File("/c/test.txt"));
To specify the export options for the specific type of text file you are exporting, use the corresponding
export-preferences object. The following script sets text-export preferences (for the complete script, see
TextExportPreferences):
//Sets the text export filter preferences.
with(app.textExportPreferences){
//Options for characterSet:
//TextExportCharacterSet.unicode
//TextExportCharacterSet.defaultPlatform
characterSet = TextExportCharacterSet.unicode;
//platform options:
//ImportPlatform.macintosh
//ImportPlatform.pc
platform = ImportPlatform.macintosh;
}
The following script sets tagged text-export preferences (for the complete script, see
TaggedTextExportPreferences):
//Sets the tagged text export filter preferences.
with(app.taggedTextExportPreferences){
//Options for characterSet:
//TagTextExportCharacterSet.ansi
//TagTextExportCharacterSet.ascii
//TagTextExportCharacterSet.gb18030
//TagTextExportCharacterSet.ksc5601
//TagTextExportCharacterSet.shiftJIS
//TagTextExportCharacterSet.unicode
characterSet = TagTextExportCharacterSet.unicode;
//tagForm options:
//TagTextForm.abbreviated
//TagTextForm.verbose
tagForm = TagTextForm.verbose;
}
Exporting text and setting text-export preferences 31
myGetBounds

Advertisement

Table of Contents
loading

This manual is also suitable for:

Incopy cs4

Table of Contents