EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - Page 75

Adobe 0046100128056 - InDesign - Mac
209 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 6: Text and Type Placing Text and Setting Text-Import Preferences 75
The following script shows how to place a text file in an existing text frame. (We omitted the myGetBounds
function from this listing; you can find it in “Creating a text frame” on page 71
,” or see the
PlaceTextFileInFrame tutorial script.)
var myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame =
myPage.textFrames.add({geometricBounds:myGetBounds(myDocument,myPage)});
//Place a text file in the text frame.
//Parameters for TextFrame.place():
//File as File object,
//[ShowingOptions as Boolean = False]
//You'll have to fill in your own file path.
myTextFrame.place(File("/c/test.txt"));
The following script shows how to insert a text file at a specific location in text. (We omitted the
myGetBounds function from this listing; you can find it in “Creating a text frame” on page 71,” o r s e e th e
InsertTextFile tutorial script.)
var myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame = myPage.textFrames.item(0);
//Place a text file at the end of the text.
//Parameters for InsertionPoint.place():
//File as File object,
//[ShowingOptions as Boolean = False]
//You'll have to fill in your own file path.
myTextFrame.parentStory.insertionPoints.item(-1).place(File("/c/test.txt"));
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). The comments in the script show the possible values for each
property.
with(app.textImportPreferences){
//Options for characterSet: TextImportCharacterSet.
characterSet = TextImportCharacterSet.UTF8;
convertSpacesIntoTabs = true;
spacesIntoTabsCount = 3;
//The dictionary property can take many values, such as French, Italian.
dictionary = "English: USA";
//platform options: ImportPlatform
platform = ImportPlatform.macintosh;
stripReturnsBetweenLines = true;
stripReturnsBetweenParagraphs = true;
useTypographersQuotes = true;
}
The following script shows how to set tagged text import preferences (for the complete script, see
TaggedTextImportPreferences):
with(app.taggedTextImportPreferences){
removeTextFormatting = false;
//styleConflict property can be:
//StyleConflict.publicationDefinition
//StyleConflict.tagFileDefinition
styleConflict = StyleConflict.publicationDefinition;
useTypographersQuotes = true;
}

Table of Contents

Related product manuals