DMED1100 InDesign Advanced Class 8. Agenda Scripting Introduction to XML 2.

25
DMED1100 InDesign Advanced Class 8

Transcript of DMED1100 InDesign Advanced Class 8. Agenda Scripting Introduction to XML 2.

Page 1: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

DMED1100InDesign Advanced

Class 8

Page 2: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

2

Agenda Scripting Introduction to XML

Page 3: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

3

Scripting is Not … Overtly challenging Only for programmers Just for long tasks

Page 4: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

4

Running Scripts Put the script in

Adobe InDesign CS4\Scripts\Scripts Panel Could also put a shortcut to the script in the

folder Open Scripts Panel

Window -> Automation -> Scripts Alt + Ctrl + F11

Double-click the script name

p. 683

Page 5: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

5

Writing ScriptsThree main supported scripting languages: JavaScript

InDesign has built-in support called ExtendScript Is cross-platform Doesn’t easily communicate with other (Non-CS)

programs File extension .js or .jsx (preferred)

p. 683

Page 6: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

6

Writing Scripts AppleScript

For the Mac OS File extension .applescript or .as

Page 7: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

7

Writing Scripts Visual Basic

For Windows Three main types:

Visual Basic Script (VBScript) Visual Basic for Applications (VBA) Visual Basic (VB 6, VB.NET)

Textbook recommends using VBScript Can edit via text editor (NotePad or NotePad++)

Could also edit using VBA Accessible from most Office software

Page 8: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

8

Writing Scripts In Excel

Developer -> Visual Basic If Developer tab is unavailable

Office Button -> Excel Options -> Popular -> Show Developer Tab in Ribbon

Page 9: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

9

Writing Scripts Any language that can connect to the

platform works C, C++, C# Perl Python JScript And many others …

Page 10: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

10

Scripting Tutorial Download

InDesignCS4ScriptingTutorial.pdf InDesignCS4ScriptingTutorialScripts.zip

Work through the tutorial

Page 11: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

11

Using the ESTK Full-featured text editor Also checks syntax of script

Edit -> Check Syntax

Make sure InDesign selected as target application

To turn on ID’s screen display Scripts Panel (ID) -> Options -> Enable Redraw

p. 700

Page 12: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

12

Monitoring Events Scripts can be run when events happen:

Opening a document Creating a new document Saving a document Closing a document Exporting

p. 710

Page 13: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

13

Menu Scripts Scripts can run menu items or add items to

menus See Adobe InDesign CS4 Scripting Guide for

more details

p. 712

Page 14: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

14

Startup Scripts Place script in a folder Startup Scripts in

Scripts folder Need to add some lines to prevent message

box

p. 712

Page 15: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

15

XML Extensible Markup Language A way to tag information in a text file

<author>Information about author</author> Not just an extension of HTML

HTML is about formatting XML is about content

p. 739

Page 16: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

16

XML Vocabulary Tag

A label for a piece of XML data Marked with angle brackets Cannot contain space characters Must be well formatted

XML Element The actual XML data

<author>Charles Dickens</author>

Page 17: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

17

XML Vocabulary Elements may contain other elements:

<author><name>Charles Dickens</name><dob>7 February 1812</dob><birthplace>Landport, Portsmouth</birthplace>

</author>

Page 18: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

18

XML Vocabulary XML Attribute

Use to add information about the element Known as Metadata

<author lastUpdate=“10/03/02”>

XML Comment Allow you to keep notes

<!-- This is a comment -->

Page 19: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

19

XML Vocabulary XML Processing Instructions

InDesign does not use Can just delete if they exist

DTD (Document Type Definition) Description of:

What elements appear The order of appearance

Not required by InDesign

Page 20: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

20

Structure View View -> Structure -> Show Structure

p. 743

Page 21: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

21

XML Tags Tags panel

Window -> Tags

p. 749

Page 22: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

22

Importing XML File -> Import XML Import Options:

Mode: Replace or Merge with existing XML Create Link: to source XML document Apply XSLT: apply a style sheet Clone Repeating Text Elements: allows automatic

placement of XML elements

p. 757

Page 23: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

23

Replacing XML Elements Select structure in Structure View Choose Import XML Turn on Replace Content Turn on Import Into Selected Element

Page 24: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

24

Exporting XML File -> Export Choose XML from Format pop-up menu

p. 762

Page 25: DMED1100 InDesign Advanced Class 8. Agenda  Scripting  Introduction to XML 2.

25

Creating Placeholders Look at pp. 763-765