Adobe 65009333 Scripting Guide

Adobe 65009333 - InCopy CS4 - PC Manual

Adobe 65009333 manual content summary:

  • Adobe 65009333 | Scripting Guide - Page 1
    ADOBE® INCOPY® CS4 ADOBE INCOPY CS4 SCRIPTING GUIDE: JAVASCRIPT
  • Adobe 65009333 | Scripting Guide - Page 2
    of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form Adobe, the Adobe logo, Creative Suite, InCopy, InDesign, Illustrator, and Photoshop are registered trademarks or trademarks of Adobe
  • Adobe 65009333 | Scripting Guide - Page 3
    details 8 Using the scripts in this document 9 Your first InCopy script 9 Walking through the script 10 Scripting terminology and the InCopy object model 10 Scripting terminology 10 Understanding the InDesign and InCopy object model 13 Measurements and positioning 16 Adding features to
  • Adobe 65009333 | Scripting Guide - Page 4
    Contents 4 Placing text and setting text-import preferences 27 Exporting text and setting text-export preferences 30 Text objects 34 Selections 35 Moving and copying text 36 Text objects and iteration 37 Formatting text 38 Setting text defaults 38 Fonts 41 Applying a font 42 Changing
  • Adobe 65009333 | Scripting Guide - Page 5
    XML element 80 Duplicating an XML element 80 Removing items from the XML structure 81 Creating an XML comment 81 Creating an XML processing instruction 81 Working with XML attributes 81 Working with XML stories 82 Exporting XML 83 Adding XML elements to a story 83 Associating XML elements
  • Adobe 65009333 | Scripting Guide - Page 6
    of the scripts shown in this document is available at the InCopy scripting home page, at: http://www.adobe.com/products/InCopy/scripting/index.html. After you have downloaded and expanded the archive, move the folders corresponding to the scripting language(s) of your choice into the Scripts Panel
  • Adobe 65009333 | Scripting Guide - Page 7
    feature in Adobe® InCopy® CS4. No other feature-no tool, panel, or dialog box you see in the program's user interface-can save you as much time, trouble, and money as scripting. This document is for every InCopy user. It does not matter if you never created a script before; this manual shows you
  • Adobe 65009333 | Scripting Guide - Page 8
    by choosing Undo from the Edit menu. This can help you troubleshoot a script, as you can step backward through each change. To 1.5 are supported. Adobe Illustrator®, Adobe Photoshop®, and other Adobe Creative Suite® features are used in several Adobe products, we consolidated all ExtendScript
  • Adobe 65009333 | Scripting Guide - Page 9
    code shown in this chapter. To do this: 1. Copy the script from this Adobe PDF document and paste it into the ExtendScript Toolkit. 2. Save the script as a script name in the Scripts panel to run the script. Entering scripts manually will only work for the scripts shown in this chapter. The scripts
  • Adobe 65009333 | Scripting Guide - Page 10
    Getting Started Scripting terminology and the InCopy object model 10 Walking through the script This section presents a step-by-step analysis of what the script above does. 1. Establish communication with the InCopy application object: Refer
  • Adobe 65009333 | Scripting Guide - Page 11
    scripting-language terms. Assigning a value to a variable Assigning values or strings to variables is fairly simple, as shown below: var myNumber = 10; var myString = "Hello, World!"; var myTextFrame = myDocument.pages.item(0).textFrames.add(); NOTE: In JavaScript, all variables not preceded by var
  • Adobe 65009333 | Scripting Guide - Page 12
    returns the string: "Pride and Prejudice" Conditional statements "If the size of the selected text is 12 points, set the point size to 10 points." This is an example of a conditional statement. Conditional statements make decisions; they give your scripts a way to evaluate something (like the color
  • Adobe 65009333 | Scripting Guide - Page 13
    words, paragraphs, and anchored frames; graphics frames contain images, EPSs, or PDFs; groups contain other page items. The things we mention here are the key to finding the object you want to work with. Your best guide to InCopy scripting is your knowledge of InCopy itself. Objects have properties
  • Adobe 65009333 | Scripting Guide - Page 14
    take; for example, finding and changing text, copying the selection, creating new documents, and opening libraries. Examples are text preferences, PDF export preferences, and document preferences. Many preferences objects also exist at the document level. Just as in the user interface, application
  • Adobe 65009333 | Scripting Guide - Page 15
    the document can take; for example, closing a document, printing a document, and exporting a document. The preferences of a document, such as guide preferences, view preferences, or document preferences. For example, the document filename, number of pages, and zero-point location. A collection of
  • Adobe 65009333 | Scripting Guide - Page 16
    on the property or method you selected: For more on using the ExtendScript Toolkit object model viewer, see Creative Suite 4 JavaScript Tools Guide. Measurements and positioning All items and objects in InCopy are positioned on the page according to measurements you specify. It is useful to
  • Adobe 65009333 | Scripting Guide - Page 17
    Getting Started Adding features to "Hello World" 17 "1p6," is returned as "1.5." InCopy does this because your scripting system would have trouble trying to perform arithmetic operations using measurement strings. For instance, trying to add "0p3.5" to "13p4" produces a script error, while adding
  • Adobe 65009333 | Scripting Guide - Page 18
    Getting Started Adding features to "Hello World" 18 //Get a reference to a font. try{ //Enter the name of a font on your system, if necessary. var myFont = app.fonts.item("Arial"); } on(myError){} //Get the active document and assign the result to the variable "myDocument" var myDocument = app.
  • Adobe 65009333 | Scripting Guide - Page 19
    3 Scripting Features This chapter covers scripting techniques that relate to InCopy's scripting environment. Almost every other object in the InCopy scripting model controls a feature that can change a document or the application defaults. By contrast, the features in this chapter control how
  • Adobe 65009333 | Scripting Guide - Page 20
    Scripting Features Getting the current script 20 Property userInteractionLevel version Description This property controls the alerts and dialogs InCopy presents to the user. When you set this property to UserInteractionLevels.neverInteract, InCopy does not display any alerts or dialogs; set it to
  • Adobe 65009333 | Scripting Guide - Page 21
    Scripting Features Script versioning 21 Script versioning InCopy CS4 can run scripts using earlier versions of the InCopy scripting object model. To run an older script in a newer version of InCopy, you must consider the following: ➤ Targeting - Scripts must be targeted to the version application
  • Adobe 65009333 | Scripting Guide - Page 22
    (1), vbOKOnly, \"First argument: \" & arguments(0)"; app.doScript(myVBScript, ScriptLanguage.visualBasic, myParameters); } else{ var myAppleScript = "tell application \"Adobe InCopy CS4\\rdisplay dialog(\"First argument\" & item 1 of arguments & return & \"Second argument: \" & item 2 of arguments
  • Adobe 65009333 | Scripting Guide - Page 23
    \", \"This is the second script argument value.\""; app.doScript(myVBScript, ScriptLanguage.visualBasic); } else{ var myAppleScript = "tell application \"Adobe InCopy CS4\"\r"; myAppleScript += "make script arg with properties{name:\"ScriptArgumentA\", value:\"This is the first script argument value
  • Adobe 65009333 | Scripting Guide - Page 24
    and execution environment. To do this, use the #targetenging statement and provide your own ExtendScript engine name, as shown in the following script fragment: #targetengine "adobe"
  • Adobe 65009333 | Scripting Guide - Page 25
    4 Text and Type Entering, editing, and formatting text make up the bulk of the time spent working on most InCopy documents. As a result, automating text and type operations can result in large productivity gains. This tutorial shows how to script the most common operations involving text and type.
  • Adobe 65009333 | Scripting Guide - Page 26
    -the starting and ending characters of the paragraph-as parameters to the itemByRange method. Inserting special characters Because the ExtendScript Toolkit supports Unicode, you can simply enter Unicode characters in text strings you send to InCopy. Alternately, you can use the JavaScript method
  • Adobe 65009333 | Scripting Guide - Page 27
    Text and Type Placing text and setting text-import preferences 27 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
  • Adobe 65009333 | Scripting Guide - Page 28
    Text and Type Placing text and setting text-import preferences 28 //TextImportCharacterSet.windowsCE //TextImportCharacterSet.windowsCyrillic //TextImportCharacterSet.windowsEE //TextImportCharacterSet.windowsGreek //TextImportCharacterSet.windowsTurkish characterSet = TextImportCharacterSet.
  • Adobe 65009333 | Scripting Guide - Page 29
    Text and Type Placing text and setting text-import preferences 29 The following script shows how to set tagged text-import preferences (for the complete script, see TaggedTextImportPreferences): //Sets the tagged text import filter preferences. with(app.taggedTextImportPreferences){
  • Adobe 65009333 | Scripting Guide - Page 30
    Text and Type Exporting text and setting text-export preferences 30 The following script shows how to set Excel import preferences (for the complete script, see ExcelImportPreferences): //Sets the Excel import filter preferences. with(app.excelImportPreferences){ //alignmentStyle property can be:
  • Adobe 65009333 | Scripting Guide - Page 31
    Text and Type Exporting text and setting text-export preferences 31 The following example shows how to export a specific range of text. (We omitted the myGetBounds function from this listing; see the ExportTextRange tutorial script.) var myDocument = app.documents.add(); var myStory = myDocument.
  • Adobe 65009333 | Scripting Guide - Page 32
    Text and Type Exporting text and setting text-export preferences 32 Do not assume you are limited to exporting text using existing export filters. Since JavaScript can write text files to disk, you can have your script traverse the text in a document and export it in any order you like, using
  • Adobe 65009333 | Scripting Guide - Page 33
    Text and Type Exporting text and setting text-export preferences 33 else{ //Handle text style range export by iterating //through the text style ranges in the paragraph. for(var myRangeCounter = 0; myRangeCounter < myParagraph.textStyleRanges.length; myRangeCounter ++){ myTextStyleRange =
  • Adobe 65009333 | Scripting Guide - Page 34
    Text and Type Text objects 34 //Close the text file. myTextFile.close(); } } } } function myFindTag (myStyleName, myStyleToTagMapping){ var myTag = ""; var myDone = false; var myCounter = 0; do{ if(myStyleToTagMapping[myCounter][0] == myStyleName){ myTag = myStyleToTagMapping[myCounter][1]; break;
  • Adobe 65009333 | Scripting Guide - Page 35
    Text and Type Text objects 35 For any text-stream object, the parent of the object is the story containing the object. To get a reference to the text frame (or text frames) containing a given text object, use the parentTextFrames property. For a text frame, the parent of the text frame usually is
  • Adobe 65009333 | Scripting Guide - Page 36
    Text and Type Text objects 36 Moving and copying text To move a text object to another location in text, use the move method. To copy the text, use the duplicate method (which is identical to the move method in every way but its name). The following script fragment shows how it works (for the
  • Adobe 65009333 | Scripting Guide - Page 37
    text while iterating through a series of text objects, you can easily end up with invalid text references. The following script demonstrates this problem (for the complete script, see TextIterationWrong): //Shows how *not* to iterate through text. var myDocument = app.documents.add(); var myString
  • Adobe 65009333 | Scripting Guide - Page 38
    Text and Type Formatting text 38 //Shows the correct way to iterate through text. var myDocument = app.documents.add(); var myString = "Paragraph 1.\rDelete this paragraph.\rParagraph 2.\rParagraph 3.\rParagraph 4.\rParagraph 5.\rDelete this paragraph.\rParagraph 6.\r"; var myStory = myDocument.
  • Adobe 65009333 | Scripting Guide - Page 39
    catch(e){} autoLeading = 100; balanceRaggedLines = false; baselineShift = 0; capitalization = Capitalization.normal; composer = "Adobe &Paragraph Composer"; desiredGlyphScaling = 100; desiredLetterSpacing = 0; desiredWordSpacing = 100; dropCapCharacters = 0; if(dropCapCharacters != 0){ dropCapLines
  • Adobe 65009333 | Scripting Guide - Page 40
    Text and Type pointSize = 11; position = Position.normal; rightIndent = 0; ruleAbove = false; if(ruleAbove == true){ ruleAboveColor = app.colors.item("Black"); ruleAboveGapColor = app.swatches.item("None"); ruleAboveGapOverprint = false; ruleAboveGapTint = 100; ruleAboveLeftIndent = 0;
  • Adobe 65009333 | Scripting Guide - Page 41
    >fontStyle, where familyName is the name of the font family, is a tab character, and fontStyle is the name of the font style. For example: "Adobe Caslon ProSemibold Italic"
  • Adobe 65009333 | Scripting Guide - Page 42
    font by specifying the font-family name and font style, as shown in the following script fragment: myText.appliedFont = app.fonts.item("Adobe Caslon Pro"); myText.fontStyle = "Semibold Italic"; Changing text properties Text objects in InCopy have literally dozens of properties corresponding to their
  • Adobe 65009333 | Scripting Guide - Page 43
    Text and Type Formatting text 43 Changing text color You can apply colors to the fill and stroke of text characters, as shown in the following script fragment (from the TextColors tutorial script): //Given two colors "myColorA" and "myColorB"... var myStory = myDocument.stories.item(0); //Enter
  • Adobe 65009333 | Scripting Guide - Page 44
    Text and Type Formatting text 44 try{ myCharacterStyle = myDocument.characterStyles.item("myCharacterStyle"); //If the style does not exist, trying to get its name generates an error. myName = myCharacterStyle.name; } catch (myError){ //The style did not exist, so create it. myCharacterStyle =
  • Adobe 65009333 | Scripting Guide - Page 45
    the most powerful InCopy tools for working with text. It is fully supported by scripting, and scripts can use find/change to go far beyond in a way that adds or removes text from a story, you might face the problem of invalid text references, as discussed in "Text objects and iteration" on page 37.
  • Adobe 65009333 | Scripting Guide - Page 46
    Text and Type Finding and changing text 46 Find/change preferences Before searching for text, you probably will want to clear find and change preferences, to make sure the settings from previous searches have no effect on your search. You also need to set a few find and change preferences to
  • Adobe 65009333 | Scripting Guide - Page 47
    .wholeWord = false; //Search the document for the 24 point text and change it to 10 point text. app.findTextPreferences.pointSize = 24; app.changeTextPreferences.pointSize = 10; app.documents.item(0).changeText(); //Clear the find/change preferences after the search. app.findTextPreferences
  • Adobe 65009333 | Scripting Guide - Page 48
    the find/change preferences after the search. app.findTextPreferences = NothingEnum.nothing; app.changeTextPreferences = NothingEnum.nothing; Using grep InCopy supports regular expression find/change through the findGrep and changeGrep methods. Regular-expression find and change also can find text
  • Adobe 65009333 | Scripting Guide - Page 49
    and changing text 49 One handy use for grep find/change is to convert text markup (i.e., some form of tagging plain text with formatting instructions) into InCopy formatted text. PageMaker paragraph tags (which are not the same as PageMaker tagged text-format files) are an example of a simplified
  • Adobe 65009333 | Scripting Guide - Page 50
    Text and Type Tables 50 function myRemoveDuplicates(myArray){ //Semi-clever method of removing duplicate array items; much faster //than comparing every item to every other item! var myNewArray = new Array; myArray = myArray.sort(); myNewArray.push(myArray[0]); if(myArray.length > 1){ for(var
  • Adobe 65009333 | Scripting Guide - Page 51
    Text and Type Tables 51 var myStory = myDocument.stories.item(0); var myStartCharacter = myStory.paragraphs.item(6).characters.item(0); var myEndCharacter = myStory.paragraphs.item(6).characters.item(-2); var myText = myStory.texts.itemByRange(myStartCharacter, myEndCharacter); //The
  • Adobe 65009333 | Scripting Guide - Page 52
    Text and Type Tables 52 The following script fragment shows how to create header and footer rows in a table (for the complete script, see HeaderAndFooterRows): var myTable = app.documents.item(0).stories.item(0).tables.item(0); //Convert the first row to a header row. myTable.rows.item(0).rowType
  • Adobe 65009333 | Scripting Guide - Page 53
    Text and Type Tables 53 The following script fragment shows how to process the selection when text or table cells are selected. In this example, the script displays an alert for each selection condition, but a real production script would then do something with the selected item(s). (For the
  • Adobe 65009333 | Scripting Guide - Page 54
    Text and Type Autocorrect 54 Autocorrect The autocorrect feature can correct text as you type. The following script shows how to use it (for the complete script, see Autocorrect): //The autocorrect preferences object turns the //autocorrect feature on or off. app.autoCorrectPreferences.autoCorrect
  • Adobe 65009333 | Scripting Guide - Page 55
    written in JavaScript also can include user interfaces created using the Adobe ScriptUI component. This chapter includes some ScriptUI scripting tutorials; for more information, see Adobe Creative Suite® 3 JavaScript Tools Guide. We assume you have already read Chapter 2, "Getting Started" and know
  • Adobe 65009333 | Scripting Guide - Page 56
    User Interfaces Your first InCopy dialog box 56 Dialog-box element Text-edit fields Numeric-entry fields Pop-up menus Control that combines a text-edit field with a pop-up menu Check box Radio buttons InCopy name Text editbox control Real editbox, integer editbox, measurement editbox, percent
  • Adobe 65009333 | Scripting Guide - Page 57
    User Interfaces Adding a user interface to "Hello World" 57 Adding a user interface to "Hello World" In this example, we add a simple user interface to the Hello World tutorial script presented in Chapter 2, "Getting Started." The options in the dialog box provide a way for you to specify the
  • Adobe 65009333 | Scripting Guide - Page 58
    User Interfaces Creating a more complex user interface 58 For the complete script, see ComplexUI. var myDialog = app.dialogs.add({name:"ComplexUI", canCancel:true}); with(myDialog){ var mySwatchNames = app.swatches.everyItem().name; //Add a dialog column. with(dialogColumns.add()){ //Create a
  • Adobe 65009333 | Scripting Guide - Page 59
    .item(mySwatchName); } } else{ myDialog.destroy() } Working with ScriptUI JavaScripts can make, create, and define user-interface elements using an Adobe scripting component named ScriptUI. ScriptUI gives scripters a way to create floating palettes, progress bars, and interactive dialog boxes that
  • Adobe 65009333 | Scripting Guide - Page 60
    User Interfaces Working with ScriptUI 60 Creating a progress bar with ScriptUI The following sample script shows how to create a progress bar using JavaScript and ScriptUI, then use the progress bar from an (for the complete script, see ProgressBar): #targetengine "session" var myProgressPanel;
  • Adobe 65009333 | Scripting Guide - Page 61
    User Interfaces Working with ScriptUI 61 For example: text FindChangeByList /c/buttons/FindChangeByList.jsx text <
  • Adobe 65009333 | Scripting Guide - Page 62
    User Interfaces Working with ScriptUI 62 return myButtonBar; } function myReadXMLPreferences(){ myXMLFile = File.openDialog("Choose the file containing your button bar defaults"); var myResult = myXMLFile.open("r", undefined, undefined); var myButtons = ""; if(myResult == true){ var myXMLDefaults
  • Adobe 65009333 | Scripting Guide - Page 63
    6 Menus InCopy scripting can add menu items, remove menu items, perform any menu command, and attach scripts to menu items. This chapter shows how to work with InCopy menu scripting. The sample scripts in this chapter are presented in order of complexity, starting with very simple scripts and
  • Adobe 65009333 | Scripting Guide - Page 64
    Menus Understanding the menu model 64 application menuActions menuAction area checked enabled eventListeners id index label name events parent title scriptMenuActions scriptMenuAction same as menuAction eventListener eventListener ... event event ... To create a list (as a text file) of all
  • Adobe 65009333 | Scripting Guide - Page 65
    Menus Understanding the menu model 65 var myMenu; //Open a new text file. var myTextFile = File.saveDialog("Save Menu Action Names As", undefined); //If the user clicked the Cancel button, the result is null. if(myTextFile != null){ //Open the file with write access. myTextFile.open("w"); for(var
  • Adobe 65009333 | Scripting Guide - Page 66
    Menus Running a menu action from a script 66 var myString = ""; var myMenuAction = app.menuActions.item("Convert to Note"); var myKeyStrings = app.findKeyStrings(myMenuAction.name); if(myKeyStrings.constructor.name == "Array"){ for(var myCounter = 0; myCounter < myKeyStrings.length; myCounter ++){
  • Adobe 65009333 | Scripting Guide - Page 67
    Menus Menus and events 67 var myMainMenu = app.menus.item("Main"); var myTypeMenu = myMainMenu.menuElements.item("Type"); var myFontMenu = myTypeMenu.menuElements.item("Font"); var myKozukaMenu = myFontMenu.submenus.item("Kozuka Mincho Pro "); var mySpecialFontMenu = myMainMenu.submenus.add("
  • Adobe 65009333 | Scripting Guide - Page 68
    Menus Working with script menu actions 68 Working with script menu actions You can use scriptMenuAction to create a new menuAction whose behavior is implemented through the script registered to run when the onInvoke event is triggered. The following script shows how to create a scriptMenuAction
  • Adobe 65009333 | Scripting Guide - Page 69
    Menus Working with script menu actions 69 about to be displayed). Among other things, the script can then change the menu names and/or set the enabled/checked status. In the following sample script, we add an eventListener to the beforeDisplay event that checks the current selection. If there is no
  • Adobe 65009333 | Scripting Guide - Page 70
    7 Events InCopy scripting can respond to common application and document events, like opening a file, creating a new file, printing, and importing text and graphic files from disk. In InCopy scripting, the event object responds to an event that occurs in the application. Scripts can be attached to
  • Adobe 65009333 | Scripting Guide - Page 71
    Events Understanding the event scripting model 71 User-Interface event Event name Any menu action beforeDisplay beforeDisplay beforeInvoke Close afterInvoke onInvoke beforeClose Export afterClose beforeExport Import afterExport beforeImport New afterImport beforeNew Open afterNew
  • Adobe 65009333 | Scripting Guide - Page 72
    Events Understanding the event scripting model 72 User-Interface event Event name Revert beforeRevert Save afterRevert beforeSave Save A Copy afterSave beforeSaveACopy Save As afterSaveACopy beforeSaveAs afterSaveAs Description Object type Appears after a document revert request is
  • Adobe 65009333 | Scripting Guide - Page 73
    Events Working with eventListeners 73 Property Description Bubbles If true, the event propagates to scripting objects above the object initiating the event. Cancelable If true, the default behavior of the event on its target can be canceled. To do this, use the PreventDefault method.
  • Adobe 65009333 | Scripting Guide - Page 74
    with the document or exported to INX. NOTE: If you are having trouble with a script that defines an eventListener, you can either run a script the application. The following sample script creates an eventListener for each supported event and displays information about the event in a simple dialog
  • Adobe 65009333 | Scripting Guide - Page 75
    Events A sample "afterNew" eventListener 75 function myEventInfo(myEvent){ var myString = "Handling Event: " +myEvent.eventType; myString += "\r\rTarget: " + myEvent.target + " " +myEvent.target.name; myString += "\rCurrent: " +myEvent.currentTarget + " " myStirng += myEvent.currentTarget.name;
  • Adobe 65009333 | Scripting Guide - Page 76
    ){ var myDocument = myEvent.parent; main(myDocument); function main(myDocument){ app.userName = "Adobe"; myAddXMPData(myDocument); } function myAddXMPData(myDocument){ with(myDocument.metadataPreferences){ author = "Adobe Systems"; description = "This is a sample document with XMP metadata. Created
  • Adobe 65009333 | Scripting Guide - Page 77
    8 XML Extensible Markup Language, or XML, is a text-based mark-up system created and managed by the World Wide Web Consortium (www.w3.org). Like Hypertext Markup Language (HTML), XML uses angle brackets to indicate markup tags (for example, or ). While HTML has a predefined set of
  • Adobe 65009333 | Scripting Guide - Page 78
    XML Scripting XML Elements 78 Setting XML preferences You can control the appearance of the InCopy structure panel using the XML view-preferences object, as shown in the following script fragment (from the XMLViewPreferences tutorial script): var myDocument = app.documents.add(); var
  • Adobe 65009333 | Scripting Guide - Page 79
    XML Scripting XML Elements 79 Importing XML Once you set the XML-import preferences the way you want them, you can import an XML file, as shown in the following script fragment (from the ImportXML tutorial script): myDocument.importXML(File("/c/completeDocument.xml")); When you need to import the
  • Adobe 65009333 | Scripting Guide - Page 80
    XML Scripting XML Elements 80 myDocument.saveXMLTags(File("/c/xml_tags.xml"), "Tag set created October 5, 2006"); Creating an XML element Ordinarily, you create XML elements by importing an XML file, but you also can create an XML element using InCopy scripting, as shown in the following script
  • Adobe 65009333 | Scripting Guide - Page 81
    .item(0); var myXMLElement = myRootXMLElement.xmlElements.item(1); myXMLElement.xmlComments.add("This is an XML comment."); Creating an XML processing instruction A processing instruction (PI) is an XML element that contains directions for the application reading the XML document. XML processing
  • Adobe 65009333 | Scripting Guide - Page 82
    XML Scripting XML Elements 82 The following script fragment shows how to add an XML attribute to an XML element (for the complete script, see MakeXMLAttribute): var myDocument = app.documents.item(0); var myRootXMLElement = myDocument.xmlElements.item(0); var myXMLElementB = myRootXMLElement.
  • Adobe 65009333 | Scripting Guide - Page 83
    XML Adding XML elements to a story 83 var myXMLStory = myDocument.xmlStories.item(0); //Though the text has not yet been placed in the layout, all text //properties are available. myXMLStory.texts.item(0).pointSize = 72; //Place the XML element in the layout to see the result. myDocument.
  • Adobe 65009333 | Scripting Guide - Page 84
    XML Adding XML elements to a story 84 var myXMLElement = myDocument.xmlElements.item(0).xmlElements.item(0); //By inserting the return character after the XML element, the character //becomes part of the content of the parent XML element, not of the element itself. myXMLElement.insertTextAsContent
  • Adobe 65009333 | Scripting Guide - Page 85
    XML Adding XML elements to a story 85 var myDocument = app.documents.item(0); //Create a style to tag mapping. myDocument.xmlExportMaps.add(myDocument.paragraphStyles.item("heading 1"), myDocument.xmlTags.item("heading_1")); myDocument.xmlExportMaps.add(myDocument.paragraphStyles.item("heading
  • Adobe 65009333 | Scripting Guide - Page 86
    XML Adding XML elements to a story 86 myPara1Style.firstLineIndent = 0; var myBodyTextStyle = myDocument.paragraphStyles.add(); myBodyTextStyle.name = "body text"; myBodyTextStyle.pointSize = 12; myBodyTextStyle.firstLineIndent = 24; //Create a character style. var myCharacterStyle = myDocument.
  • Adobe 65009333 | Scripting Guide - Page 87
    .colors.item("Black"); myTableStyle.startRowFillTint = 25; myTableStyle.endRowFillColor = myDocument.colors.item("Black"); myTableStyle.endRowFillTint = 10; var myCellStyle = myDocument.cellStyles.add(); myCellStyle.fillColor = myDocument.colors.item("Black"); myCellStyle.fillTint = 45 //Add
  • Adobe 65009333 | Scripting Guide - Page 88
    .xmlElements.item(0).applyCellStyle(myCellStyle); myTableXMLElement.xmlElements.item(5).applyCellStyle(myCellStyle); myTableXMLElement.xmlElements.item(10).applyCellStyle(myCellStyle); myTableXMLElement.xmlElements.item(15).applyCellStyle(myCellStyle); myTableXMLElement.xmlElements.item(16
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

ADOBE
®
INCOPY
®
CS4
ADOBE INCOPY CS4
SCRIPTING GUIDE:
JAVASCRIPT