sys-To embed a profile, select the profile from the Profile pop-up menu in the Preflight panel, then click the Embed Profile button to the left of the pop-up menu.. To save a preflight r
Trang 1A key point here is that the preflight warnings do not, by selves, mean that something is wrong with your document Even the warnings produced by the Basic profile are not necessarily bad It all depends on your workflow and printing process For example, the Basic profile will always flag images that use the RGB color space It might be that RGB images are fine in your workflow—it’s up to you
them-to decide whether them-to ignore the error message or not In similar ion, you might want to set up custom profiles that alert you to benign, but possibly unexpected, conditions in your documents
fash-Defining preflight profiles To define a preflight profile, follow these
steps (see Figure 11-18)
1 Display the Preflight panel
2 Choose Define Profiles from the Preflight Panel menu InDesign displays the Preflight Profiles dialog box
3 Click the New Preflight Profile button (“+”)
4 Enter a name for your new profile
5 Work your way through the different areas of the dialog box, turning preflight checks on and off as necessary
6 When the preflight profile includes all of the checks you want it
to, click the OK button to save the profile
To use the profile, select the profile name from the Profile pop-up menu in the Preflight panel To edit the profile, return to the Preflight
Figure 11-17 Preflight Panel Choose Preflight Panel from the Preflight pop-up menu Use the Preflight Document
option turn the Preflight feature on or off.
If preflight is on, you can double-click the Preflight icon
to display the panel.
The Preflight panel gives you a quick look at the status of the preflight check If anything is amiss (according to the current prflight profile), you’ll see it
reported here.
When you select an item in the Error list, the Info area shows more detail about the error.
Click the link to go to the page containing the error.
Define the range of pages you want to check using these controls.
Choose the preflight profile you want to use.
Click this icon to embed the preflight profile in the document.
Trang 2Figure 11-18 Defining a Preflight Profile
Profiles dialog box, select the profile name in the list of profiles The Preflight panel will fill in with the conditions you’ve defined for the profile Make any changes to the profile you want, then click the Save button to save the profile
Performing a preflight check Once you’ve selected a preflight
pro-file, all you need to do is turn it on To do this, display the Preflight panel (choose Preflight Panel from the Preflight pop-up menu), then turn on the On option You can control the range of pages checked using the options at the bottom of the Preflight panel
As InDesign checks your document against the preflight tions defined in the profile, any errors found will appear in the Pre-flight panel Links in the Preflight panel will take you to each error
condi-Embedding preflight profiles You can embed a preflight profile in a
document, which means that the document can travel to other tems and still be checked for the conditions you defined in the profile
sys-To embed a profile, select the profile from the Profile pop-up menu
in the Preflight panel, then click the Embed Profile button to the left
of the pop-up menu
Saving Preflight Reports To save a preflight report (the list of errors
shown in the Error section of the Preflight panel) as a text file or PDF, choose Save Report from the Preflight panel menu InDesign
Click the + button to add a
new Preflight profile.
InDesign displays the settings for a new profile
Work your way through the settings to define the error conditions you want to look for during a preflight check.
Trang 3Figure 11-19 Preflight Options Dialog Box
displays a standard file dialog Enter a file name and folder for the file, then choose the format you want to use to save the report from the Save As Type pop-up menu Click the OK button to save the report
Setting Preflight Options The Preflight Options dialog box (choose
Preflight Options from the Preflight panel menu) gives you a way to define various settings for the way that InDesign interprets and uses preflight profiles (see Figure 11-19)
Settings in this dialog box are pretty much self-explanatory: choose whether you want to use a particular profile as a default, whether you want the profile to check master pages and page items
on the pasteboard, and so on If you ever work with files created by others, we think you should keep the Use Embedded Profile option turned on—this is the default for good reason Without it, you might not notice the profile someone else has set up, and end up “correct-ing” mistakes that aren’t mistakes at all
You can assemble all of the files needed to print the publication using the Package plug-in (this is similar to QuarkXPress’ “Col-lect for Output” feature, or PageMaker’s “Save For Service Provider” plug-in) InDesign also creates a report containing detailed informa-tion about your document, including fonts and pictures you used Then all you have to do is get the folder to your output provider
To “package” a publication, follow these steps (see Figure 11-20)
1 Choose Package from the File menu (or press Command- Option-Shift-P/Ctrl-Alt-Shift-P) InDesign displays the Printing Instructions dialog box
2 Enter contact information in the Printing Instructions dialog box—this information will appear in the final text report that InDesign adds to the package you’re creating
Package
Trang 4When you choose Package from the File menu
(or click the Package button
in the Preflight dialog box),
InDesign displays the Printing Instructions
dialog box.
Enter your contact information and any notes you want to include in the fields;
these instructions will
be saved as a text file.
After you click the Continue
button, InDesign displays
the Package Publication
dialog box.
Choose the files you want to
copy to the package folder.
Enter a name and location for the pack- age (the publication file and any other files you choose to copy).
Click Package to save the document and associated files to the folder you selected.
If you’re copying fonts, InDesign displays this message after you click the
Package button
Figure 11-20 Packaging a Publication
for Remote Printing
3 Click the Continue button InDesign displays the Create age Folder dialog box Set the options you want and enter a name for the folder that will contain the packaged publication.When you turn on the Copy Fonts or Copy Linked Graphics option, InDesign copies the files to the folder you specify The Update Graphic Links in Package option tells InDesign to set the links for non-embedded images to the images in the pack-aged folder (rather than leaving them linked to the original files) It’s pretty rare that you’d want to turn this off When you turn
Pack-on the Use Document HyphenatiPack-on ExceptiPack-ons Only optiPack-on, InDesign flags this document so that it won’t reflow when
Trang 5someone else opens or edits it on a machine that may have ferent dictionaries and hyphenation settings We generally turn this on when sending the file to an output provider.
dif-4 Click the Package button InDesign creates the folder and copies the publication and the files you specified into it If the Copy Fonts option was turned on, InDesign also alerts you that copy-ing fonts may be a violation of your rights Adobe fonts can be copied to send to an output provider, but some font vendors don’t allow this (though we’ve never heard of anyone being taken to court for this)
When you send this folder full of files to your printer or vice bureau, make sure you remind them that there is a file called Instructions.txt in there that they should read In fact, we sometimes rename this file “READ ME.txt” to make it stand out better
ser-Finally, if you’re working on really large files with hundreds of megabytes of images, you need to be careful with the Package feature
so that you don’t run out of hard disk space
All the News That Prints to Fit
Printing is all about thinking ahead When you create a new lication, you really should be thinking “How the heck are we going
pub-to print this thing?” By the end of the production process, you’ll be tired, cranky, and less able to deal with any problems that come up—
so make your decisions about paper size, color selection, and graphic file types as early as you can
Trang 6Most of the time, we tell a program (an application, a plug-in, or our system software) what to do by manipulating the program’s user interface—we click, drag, and type Scripting is a way of telling a program to perform the same tasks and accomplish the same things
The difference is that, with scripting, we don’t have to click the tons, type the characters, or choose the menu items The script does it
but-for you Scripting is what computing is supposed to be about: having
your computer take over boring, repetitive tasks so that you can
spend more time playing World of Warcraft: Wrath of the Lich King
Er, we mean, concentrating on your creative work
Scripting also gives you the ability to add the features you need
to InDesign now, rather than waiting for Adobe to give them to
you Even better than that, scripting gives you a way to customize InDesign to match your publications and habits to a degree that
Adobe is never going to provide.
We’re convinced that the reason many people have not taken up scripting is that they’re scared They think scripting is difficult, and
is only for people with advanced computer science degrees And they tell themselves that they’re too “intuitive” and “artistic” to master the minimal analytical skills required to write a script
Trang 7Be Not Afraid
You do not need to know how to write scripts to be able to run scripts
This is a misunderstanding that prevents many people from even trying scripting, even though existing scripts might save them enor-mous amounts of time and trouble
Even if you don’t want to write scripts, or know anything about how they’re written, you can use scripts For that matter, chances
are quite good that you know someone who is interested in
writ-ing scripts for you, and would be willwrit-ing to do so for the occasional expression of admiration (or beer)
All you need to know is how to install scripts—and that’s very simple: just put the script in the Scripts Panel folder in the Scripts folder inside your InDesign folder When you do this, the script will appear
in the Scripts panel in InDesign You can also put an alias (Mac OS)
or shortcut (Windows) to a script or folder in the same folder That's all there is to it
That’s pretty simple, right? If not, we’re not certain you should be using a computer at all (or driving a car, for that matter)
To run a script, double-click the script name in the Scripts panel There are a few other options, as discussed in “Using the Scripts Panel and the Script Label Panel,” later in this chapter Many scripts will display a dialog box (or other user interface item)
Next, we encourage everyone to consider learning to write scripts
Ole says: “Look I’m practically a high school dropout, and my background is in illustration, not computer science I have never taken a single class on programming As a rebellious teenager I did
my best to ignore the sciences and to panic at the sight of even simple equations (in psychoanalytical terms this makes sense: my father was
a high school algebra teacher)
“I got over it These days, I write scripts You can, too.”
System Requirements
What do you need to write and run scripts for InDesign? The ing things:
follow-▶ The standard scripting system for your computer (if you plan
to use the platform-specific scripting languages rather than JavaScript) You probably already have this
Installing Scripts
Running a Script
Writing Scripts: How
Hard Could It Be?
Trang 8▶ The InDesign scripting documentation and sample scripts.
▶ A good understanding of the way InDesign works
Extend-InDesign JavaScripts are cross-platform—they run in both the Windows and Mac OS versions of InDesign There are a few minor differences between platforms—but they’re limited to the way that the scripts work with files and the operating system (as you’d expect)
If JavaScript is cross-platform, why does Adobe bother supporting the platform-specific languages? First, because scripters might prefer
those languages Adobe’s goal should be to increase the number of
lan-guages that can be used, not to limit them Next, because InDesign’s JavaScript does not know how to communicate with other applica-tions on your system (such as FileMaker or Access); the platform-specific languages do that very well
Luckily, we can use both, and we can tie the platform-specific and platform-independent languages together with InDesign’s “do script” method, which lets scripts run other scripts A JavaScript, for example, can run an AppleScript, or a VBScript can run a JavaScript For an example of the latter, take a look at the FindChangeByList.vbs example script, where Ole uses a snippet of JavaScript to add a file browser dialog box to a VBScript
Note: Some InDesign JavaScripts have the file extension “.js”, which
is the standard extension for JScripts in Windows, they will not work
if run from the operating system (at best, you’ll get an error message) Instead, run these scripts using InDesign’s Scripts panel Try to get in the habit of using the “.jsx” extension, rather than “.js”
On the Mac OS, all you need is AppleScript You almost certainly already have it installed, but in case you don’t, it comes on the Mac installation CD If you can’t find your installation CD, you can download AppleScript directly from Apple (http://www.apple.com) What’s the easiest way to tell if it’s installed? Search for a file named
“Script Editor” (this is the application you use to write and run
JavaScript
Mac OS
Trang 9AppleScripts) If you can’t find it, you’ll have to install it from the Mac OS X installation CD.
Alternative script editors are available—if you’re planning to do serious AppleScript development, we strongly recommend Script Debugger, from Late Night Software (http://www.latenightsw.com) Script Debugger is an astonishingly good piece of software, well worth its purchase price And no, we are not paid to say this
InDesign can run uncompiled AppleScripts—script files saved as text To use an uncompiled AppleScript, save the file with the file extension “.applescript” (or “.as”) in the Scripts Panel folder inside the Scripts folder in your InDesign folder, and then run the script from the Scripts panel
On the Windows side, you’ve got a number of options There are (at least) three different scripting systems claiming to be the system stan-dard: Visual Basic Script (VBScript), Visual Basic for Applications (VBA), and various forms of Visual Basic (VB)—including Visual Basic 6, Visual Basic NET, and Visual Basic 5 Control Creation Edi-tion (VB5 CCE) They’re all from Microsoft, and they’re all variants
of the Basic programming language Almost all of them work
Our Recommendation: Use VBScript To write a VBScript, all you
need is a text editor Notepad does the job quite handily You don’t need anything to run a VBScript—you can run them from Explorer
or from InDesign’s Scripts panel If you run them from InDesign’s Scripts panel, though, they’ll run much faster
Using VBScript makes distributing and deploying your scripts easier, too Since they’re just text, they’re easy to post on web pages or send to other people
The InDesign sample scripts are provided in VBScript, so you’ll have a lot of code to work with that won’t require much translation (as it would if you were to try to use them in VB.NET, for example)
Our Further Recommendation: Use VBA to develop VBScripts
Troubleshooting (debugging) VBScripts can be difficult All you can
do is run the script and then note any error messages that appear—and they’re not particularly useful What you need is a real program-ming environment, where you can step through the lines of your script one by one, as you can when you use Visual Basic
Visual Basic for Applications, the version of Visual Basic that’s built into most Microsoft Office applications, works quite well for developing VBScripts for InDesign Chances are pretty good that you’ve already got an Office application
Windows
Trang 10VBA works very well for developing VBScripts for use in InDesign You can write your VBScript in VBA, making certain that you don’t use part of Visual Basic that does not exist in VBScript; debug the script, and then, when everything works the way you want
it to, copy the contents of the subroutine to a text editor and save it as
a VBScript (.vbs) file We’ll talk more about this later in the chapter
About VB.NET (and newer versions) VB.NET is a tremendous step
backwards for the Visual Basic language in terms of performance, ease of use, and ease of learning We could rant for hours (and have) about how messed up VB.NET is (at least from the standpoint of a scripter), but, for now, we’ll content ourselves with saying that the
only reason one should use VB.NET for InDesign script development
is if your script depends on some feature of VB.NET that is not able in any of the other, better, versions of Visual Basic
avail-We can’t think of any, right at the moment
In addition, and though InDesign works with VB.NET, there are some InDesign scripting tasks that are much more difficult in VB.NET than they are in other versions of Visual Basic
Finally, if you plan on deploying your scripts as VBScripts, VBA makes a better development system than VB.NET, as VB.NET does not understand the Variant data type Because Variant is the funda-mental VBScript data type, this is a problem
We know of InDesign scripters who are using C#, C, C++, Perl, Python, JScript, OSA JavaScript, Delphi, and other languages to drive InDesign If your favorite programming language can connect
to the platform standard means of passing messages between cations (that’s OSA/AppleEvents on the Mac OS and DDE/COM in Windows), it can probably communicate with InDesign
appli-We’re not going to spend any time on those languages, ever, because, frankly, we have more than enough to do explaining VBScript, AppleScript, and JavaScript Forgive us
how-Learning About InDesign Scripting
Once you’ve gathered and installed the software you need to start scripting, you need to learn about how InDesign implements script-ing You’re in luck—you’ll find the scripting documentation, sample scripts, on the InDesign scripting home page:
http://www.adobe.com/products/indesign/scripting/index.html
Other Scripting Languages
Trang 11Once you’re there, you’ll need to click the Scripting Resources tab
to display the scripting-specific goodies
The Adobe InDesign CS4 Scripting Tutorial is a PDF that contains
an introduction to scripting, and basic tutorials (including
introduc-tory scripts) The Adobe InDesign CS4 Scripting Guide comes in three
flavors: AppleScript, JavaScript, and Visual Basic Pick the one that matches the language you want to work with
In addition, the InDesign scripting forum is at:
“newbie” questions—we’ve all been there!
You’ll find a number of sample scripts in the Scripts Panel folder inside the Scripts folder in your InDesign folder (you can also see them in the Scripts panel) Even if you don’t intend to write scripts
of your own, you might find something useful in the sample scripts Note that the InDesign scripting home page mentioned above also contains a downloadable archive of these scripts, and that Ole some-times updates the scripts to fix bugs or add features
▶ AddGuides Draws guides around the currently selected object
or objects This script shows you how to get positioning tion back from InDesign, and how to create ruler guides
informa-▶ AddPoints Adds points to a path: each point is added at the
midpoint of each line segment in a path This script strates simple Bezier math and path and point manipulations
demon-▶ AdjustLayout Moves the page items of even/odd pages by
speci-fied distances Use this script to move objects back into the rect position after adding pages or applying master pages
cor-▶ AlignToPage How many times have you wanted to position an
object in the center of the page? This script does that, and many other page alignments—including the ability to align the objects relative to the page margins
▶ BreakFrame Removes the selected text frame and its contents
from the story This feature has been frequently requested by PageMaker users Doesn’t really work when tables span multiple text frames
Example Scripts
Trang 12▶ CornerEffects Ever want to round one or two corners of a
rect-angle, while leaving the other corners square? If you have, then this script is for you The script redraws the path and applies a corner effect to a pattern of corners you specify
▶ CreateCharacterStyle When you create a character style in
InDesign by basing the style on the selected text, InDesign records only those attributes that differ from the default for-matting of the surrounding text While this is a powerful and flexible way of working with character styles, it’s also different from the way that other applications (such as QuarkXPress and FrameMaker) work In those applications, character styles apply every formatting attribute The CreateCharacterStyle script creates a new character style based on the selected text and defines every formatting attribute
▶ CropMarks Draws crop and registration marks around the
selected object or objects Like AddGuides, this script shows how
to create new objects around existing objects
▶ ExportAllStories Exports all of the stories in a document to a
specified folder using the file format of your choice (RTF, tagged text, or text only) Shows how to traverse all stories in a docu-ment and how to export text
▶ FindChangeByList Runs a sequence of find/change operations
on the selected text The find/change parameters are stored in
a tab-delimited text file (it should be in a folder named ChangeSupport inside the same folder as the sample script)
Find-By default, these searches cover the standard stuff: changing double spaces to single spaces, changing double returns to single returns, changing double dashes to em dashes, and so on—but you can add your own favorite searches to the text file (including the ability to find/change formatting) You’ll find instructions
at the beginning of the script, and in the corresponding find/
change file
▶ ImageCatalog Places all of the graphics in a folder in a grid in
an InDesign document
▶ LabelGraphics Adds a caption below every graphic in the
document The caption can be the file name, the file path, the XMP author name, or the XMP description You can control the placement of the caption relative to the frame, the style used to format the caption, and the layer for the caption
Trang 13▶ Label Graphics Menu Adds a menu item to the Context menu
when a graphic is selected Offers the same options as the Graphics script
Label-▶ MakeGrid Splits the selected frame into a grid of frames If the
frame contains content, the script can duplicate the frame
▶ Neon Creates a simple “glow” effect by duplicating the selected
path or paths Each copy of the path is slightly smaller than the original, and slightly lighter The final duplicate path is a white hairline The resulting group of paths is something like an Illus-trator blend
▶ PathEffects This script includes the ever-popular Illustrator,
path effects “Bloat” and “Punk,” as well as a few others If you want to learn about scripting InDesign paths, path points, con-trol handles, and Bezier math, this is a good place to start
▶ PlaceMultipagePDF InDesign CS4 can place all of the pages in
a multi-page PDF, but it’s a manual process—you have to click the place icon for each PDF page you want to place This script places all of the pages of a PDF on sequential pages, placing one PDF page per page, adding pages to the document if necessary as
it does so
▶ SelectObjects Selects all of the objects on a spread that belong to
a specific object type (or set of types) This script is only slightly useful by itself, but it shows you how to traverse the objects on a spread to find objects based on their type or content As such, it’s
a great starting point for any graphic “search and replace” tion you might want to implement
opera-▶ SortParagraphs Alphabetically sorts the paragraphs in the
selection Shows how to sort text using a simple “bubble sort”
algorithm, and how to move text in an InDesign story
▶ SplitStory Converts each text frame in the selected story to
an independent text frame (story), retaining the content in the frames Doesn’t really work when tables span multiple text frames
▶ TabUtilities This script automates two tasks: setting a right tab
stop at the right margin of a paragraph, and setting a left tab at the current cursor position Select some text in a single-column text frame, then click the Tab at Right button to set a tab stop at the right edge of the text column (this will also remove any
Trang 14existing tab stops in the paragraph) Click the Tab at Cursor button to set a left tab at the current cursor position.
When you launch InDesign, you’re probably aware that you’re not really launching a single program—you probably know that you’re starting a plug-in manager and several hundred plug-ins
What you probably don’t know is that each plug-in is responsible for its own scripting support, and that InDesign’s scripting object model—the library of objects and the properties and methods of those objects that make scripting work—is created anew each time you change your plug-in configuration
In other applications that support scripting, the developers try
to determine what features users of their product might want to automate They then provide scripting support for those features The trouble with this approach, of course, is that they always miss something—and their users, in the field, are stymied The users then complain, and are generally given the response, “Why would anyone want to do that?” (Translation: “We didn’t think of that.”)
InDesign scripting doesn’t work that way InDesign provides scripting access to everything (well, almost everything) you can do
to the database that is an InDesign document
Thinking About Scripting
Because scripting is a great tool for automating large, repetitive tasks,
many of us think that that’s all it’s good for But there’s far more to
scripting than that Scripting is also good at little things—operations that might save you only a few seconds a day, but can make your work easier or more precise
By “little things,” we means scripts that save you only a few mouse clicks, drags, or key presses at a time It’s these tiny tasks, repeated dozens, hundreds, or even thousands of times day by day, that add up
to fatigue, irritation, and repetitive motion injuries When you take
a common task that involves some number of actions and replace it with a simple double-click or keystroke (all it takes to run a script), you reduce the difficulty and complexity of your work
Scripting, which many of us think of as being somehow opposed
to the creative process, can be a powerful creative tool We often imagine effects we’d like to use in a publication layout that would
be difficult to accomplish by hand When there’s time, we turn to scripting for help Frequently, in the course of working on a script,
InDesign Scripting
Philosophy
Trang 15we’ll find a variation on the effect that leads us in an entirely new ative direction Scripting gives us time to experiment—and we think experimentation has a lot to do with creativity.
cre-What we’re getting at here is that scripting is what you make of it, and how you think about it If you only think of scripting as some-thing applicable to massive projects, you’re missing out on many of the benefits—and most of the fun
Using the Scripts Panel and the Script Label Panel
InDesign includes two scripting-related plug-ins: the Scripts panel and the Script Label panel The Scripts panel gives you a way to run scripts without leaving InDesign, and significantly speeds script exe-cution; the Script Label panel gives you a way to enter text into the Label property of a page item (a text frame, graphic line, a rectangle,
an oval, or an ellipse)
To display the Scripts panel, choose Scripts from the Automation submenu of the Window menu (see Figure 12-1) The Scripts panel displays the scripts (and folders) stored inside the Scripts Panel folder inside the Scripts folder in your InDesign folder
In general, we think it’s better to store your scripts somewhere else, and place aliases (on the Mac OS) or shortcuts (in Windows) in this folder Why? We’ve accidentally deleted all of our scripts by re-installing InDesign more than once It’s painful
To run a script, double-click the script in the Scripts panel To edit
a script, hold down Option/Alt and double-click the script InDesign will open the script in your script editor (or in the ExtendScript Tool-kit, for JavaScript files) To delete scripts from the Scripts panel, open the Scripts Panel folder inside the Scripts folder in your InDesign folder and move the scripts to another location (or delete them)
To open the folder containing a script, hold down Shift/Ctrl-Shift and double-click the script name in the Scripts panel InDesign will open the folder containing the script in the Finder or Windows Explorer
Command-Adding Keyboard Shortcuts to Scripts You can add keyboard
shortcuts to scripts, just as you can to menu items When you open the Edit Shortcuts dialog box, you’ll find a list of installed scripts in the Scripts section You assign a keyboard shortcut to a script in the same way that you assign any other keyboard shortcut
Scripts Panel