1. Trang chủ
  2. » Công Nghệ Thông Tin

Real World Adobe InDesign CS4- P25 pps

30 248 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Real World Adobe InDesign CS4
Trường học University of Design and Technology
Chuyên ngành Design Software
Thể loại Thesis
Năm xuất bản 2009
Thành phố Unknown
Định dạng
Số trang 30
Dung lượng 673,22 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

The Hyper-links panel also includes the Cross-References panel; we discuss cross-references in Chapter 3, “Text.” Named versus Unnamed Hyperlinks When you make a hyperlink, you need to d

Trang 1

The following script fragment shows the heart of our NINA drawing script—for the complete script, go to David’s web site (see “Where to Get the Scripts in this Chapter,” earlier in this chapter)

function myDrawNina(myNumberOfLines, a_pulse, b_pulse, myLength, myClosedPath){

var cur_x, cur_y;

var myAnchor = new Array(2);

var myArray = new Array;

//Rather than draw the entire path point-by-point, //we'll fill an array and then use it to fill in all of the point //locations at once using the entirePath property.

for (var myCounter = 0; myCounter < myNumberOfLines; myCounter++){ cur_x = (Math.cos((-2 * Math.PI * a_pulse * myCounter) / myNumberOfLines) + Math.cos((-2 * Math.PI * b_pulse * myCounter) / myNumberOfLines)) * myLength;

cur_y = (Math.sin((-2 * Math.PI * a_pulse * myCounter) / myNumberOfLines) + Math.sin((-2 * Math.PI * b_pulse * myCounter) / myNumberOfLines)) * myLength;

myAnchor = [cur_x, cur_y];

myArray.push(myAnchor);

} app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

var myPage = app.activeWindow.activePage;

var myGraphicLine = myPage.graphicLines.add();

myGraphicLine.move(undefined, ["1p","1p"]);

var myPath = myGraphicLine.paths.item(0);

//Now set the entire path to the contents of the array.

myPath.entirePath = myArray;

if(myClosedPath == true){

myPath.pathType = PathType.closedPath;

} else{

myPath.pathType = PathType.openPath;

} //Label the graphic line with the parameters used to create it.

myGraphicLine.label = "number_of_lines = " + myNumberOfLines + ", a_pulse = " + a_pulse + ", b_pulse = " + b_pulse;

}

The following script fragment shows the heart of our NINA drawing script—for the complete script, go to David’s web site (see “Where to Get the Scripts in this Chapter,” earlier in this chapter) As usual, “_” indicates a line break in this layout; do not break the line or type the character)

Function myDrawNina(myInDesign, myNumberOfLines, a_pulse, b_pulse, _ myLength, myClosedPath)

pi = 3.14159265358979 Set myDocument = myInDesign.ActiveDocument

JavaScript

Visual Basic

Trang 2

chapter 12 scripting 709

Set myPage = myInDesign.ActiveWindow.ActivePage ReDim myArray(myNumberOfLines)

Rem Fill in an array with point locations.

For myCounter = 0 To (myNumberOfLines) cur_x = (Cos((-2 * pi * a_pulse * myCounter) / myNumberOfLines) _ + Cos((-2 * pi * b_pulse * myCounter) / myNumberOfLines)) * _ myLength

cur_y = (Sin((-2 * pi * a_pulse * myCounter) / myNumberOfLines) _ + Sin((-2 * pi * b_pulse * myCounter) / myNumberOfLines)) * _ myLength

myArray(myCounter) = Array(cur_x, cur_y) Next

Set myGraphicLine = myPage.GraphicLines.Add Rem Move the graphic line a bit to clear up Rem page "ownership" issues.

myGraphicLine.Move , Array("1p", "1p") Rem Set the points on the path to the array generated by the loop myGraphicLine.Paths.Item(1).EntirePath = myArray

Rem Label the NINA with settings.

myGraphicLine.Label = "number_of_lines = " & CStr(myNumberOfLines)_ & ", a_pulse = " & CStr(a_pulse) & ", b_pulse = " & CStr(b_pulse)

If myClosedPath = True Then myGraphicLine.Paths.Item(1).PathType = idPathType.idClosedPath Else

myGraphicLine.Paths.Item(1).PathType = idPathType.idOpenPath End If

End Function

To test the NINA drawing script, move InDesign’s ruler zero point

to the point at which you want to locate the center of the shape, then run the script (we recommend setting the publication’s measurement system to points before running the script) If all goes well, InDesign will draw a NINA We urge you to experiment with the settings in the script—the number of different types of shapes you can draw is truly endless Even very slight changes to the settings can produce wildly differing results

InDesign scripts can create their own dialog boxes, and can populate those dialog boxes with static text labels, check box controls, pop-up menus, text entry fields, and a variety of number entry fields (mea-surement units, integers, percentages, and real numbers) Previously, adding a user interface to a script meant you had to rely on addi-tional user interface building software, such as FaceSpan, Real Basic,

or AppleScript Studio on the Mac OS, or the full version of Visual Basic in Windows Having to rely on these add-on products made your scripts larger, and complicated sharing scripts with others

There’s good news and bad news about InDesign script dialog boxes The good news is that InDesign takes care of all spacing and sizing issues The bad news? InDesign takes care of all spacing and

Testing the NINA Drawing Script

Adding a User Interface

Trang 3

sizing issues This means that you don’t have to worry about setting pixel coordinates for every control, but it also means that you have very little control over the appearance of your dialog boxes At the same time, it’s relatively easy to create a good-looking dialog box.

The NINA drawing script a good one to add a user interface to—all you need is a dialog box containing four text fields (to set the myNumberOf Lines, a_pulse, b_pulse, and myLength variables) and OK/Cancel buttons

We’ve provided a version of the NINA drawing script with a user interface—you can download it from David’s web site (see “Where to Get the Scripts in this Chapter,” earlier in this chapter) When you run the script, InDesign will display a dialog box (see Figure 12-8) Use the version with the user interface, and you won’t have to edit the script to draw different NINAs

Mystic Rose

Another interesting geometric figure is the “Mystic Rose”—a gon where every point connects to every other point Ole thought it would be fun to have a script that would draw these, so he wrote one (see Figure 12-9) We’ve included this script with the other scripts in the Zip archive you can download from David’s web site (see “Where

poly-to Get the Scripts in this Chapter,” earlier in this chapter)

Monitoring Events

“Events” are things that happen in InDesign Opening a file, printing

a file, importing a graphic, and moving an object are all examples of events InDesign can watch for a certain set of events, and can run scripts when those events occur The set of events that InDesign can respond to is, at present, rather limited You can monitor the follow-ing events (the event names are shown in parentheses)

▶ Opening a document (beforeOpen, afterOpen)

▶ Creating a new document (beforeNew, afterNew)

▶ Saving a document (beforeSave, afterSave, beforeSaveACopy, afterSaveACopy, beforeSaveAs, afterSaveAs)

▶ Closing a document (beforeClose, afterClose)

▶ Exporting (beforeExport, afterExport)

Trang 4

chapter 12 scripting 711

▶ Displaying a menu (beforeDisplay, afterDisplay, beforeInvoke, afterInvoke, onInvoke)

▶ Printing a document (beforePrint, afterPrint)

▶ Placing a file (beforeImport, afterImport)

▶ Reverting a document (beforeRevert, afterRevert)While this list is limited, there are a number of great places here

to have scripts run automatically You can use the beforePrint event, for example, to trigger a custom preflight script A script attached to the afterNew event add XMP metadata (“file info”) to the document.One important thing to note about event scripting: JavaScripts can process the events using functions inside the event handling script, but AppleScript and VBScript event scripts must call external scripts That’s why the AppleScript and VBScript sample script fold-ers include a folder containing three additional scripts (relative to the JavaScript version)—they make the LabelGraphicMenu script work

Take a look at the “Events” chapter in the Adobe InDesign CS4 Scripting Guide for more on attaching scripts to events.

InDesign dialog boxes can include a range of controls not shown in this example, including pop-up menus, check boxes, and a variety of other number and text entry fields (only measurement edit box controls and integer edit box controls are shown here) As in all other InDesign numeric entry fields, you can do arithmetic and enter measurement overrides in these fields.

Figure 12-8 NINA User Interface

By adding a user interface

to your script, you can make

it much easier to use This

example dialog box was

gen-erated by InDesign—no

Dia-logDirector, no AppleScript

Studio, no Visual Basic

form How cool is that?

Figure 12-9 Mystic Rose

Trang 5

Menu Scripting

InDesign scripting can run any menu item, and can associate scripts with new menu items Thanks to the events mentioned in the pre-vious section, scripts associated with menu items (most notably the Context menus) can check the selection to see whether they should display themselves or not A script can check to see that a graphic is selected, for example, before it displays a menu items for working with a graphic

Because the process of attaching a script to a menu item is fairly complicated, we’re not going to show an example here We thought, however, that we’d mention it as something you should keep in mind

If you’re curious about what it takes to add a script to a menu item,

take a look at the “Menus” chapter in the Adobe InDesign CS4 ing Guide for your preferred scripting language.

Script-Startup Scripts

If you have a script you really like, and want to have the script run whenever you start InDesign, you can There’s no real trick to it: just put the script inside a folder named “Startup Scripts” anywhere in the Scripts folder in your InDesign folder When you do this, the script will run whenever you launch InDesign

At the same time, some scripts will need modification to be run

as startup scripts Take, for example, the very useful sample script LabelGraphicMenu that comes with InDesign This script installs

a new menu item on the Context menu when you have a graphic selected Choose the menu item, and you can easily add a caption to the graphic (see Figure 12-18)

The only trouble with this script is that it asks (politely) if it can do what it does whenever you run it You don’t want to have to respond

to this question every time you start InDesign, so you’d better make

a change to the script before you put it in the Startup Scripts folder

If you’re using AppleScript or VBScript, you’ll also have to move

a folder containing three “helper” scripts to the same folder as the script itself

To convert the sample script LabelGraphicsMenu.applescript to a startup script, follow these steps

1 Open the script with your script editor

2 Locate the line:

AppleScript

Trang 6

chapter 12 scripting 713

set myResult to display dialog myString buttons{"Yes", "No", default button: "Yes"}

3 Enter “ ” before the start of the line to make it a comment

4 Locate the line:

if button returned of myResult is "Yes" then

And change it to:

if true then

5 Save the script

6 Put the edited version of the script and the LabelGraphic Support folder inside a folder named “Startup Scripts” in the Scripts folder inside your InDesign folder Create the folder if it does not already exist

To convert the sample script LabelGraphicMenu.jsx to a startup script, follow these steps

1 Open the script with the ExtendScript Toolkit

2 Locate the line:

var myResult = confirm("This script installs a new menu item 'Label Graphic' \ron the context menu that appears when you select one or more graphics.\r\rClick the Yes button to add the menu item.");

And change it to:

var myResult = true;

3 Save the script

4 Put the edited version of the script inside a folder named

“Startup Scripts” in the Scripts folder inside your InDesign folder Create the folder if it does not already exist

To convert the sample script LabelGraphicMenu.vbs to a startup script, follow these steps

1 Open the script with your script editor

2 Locate the line:

myResult = MsgBox(myString, vbOKCancel, "Install Label Graphic menu item?")

JavaScript

VBScript

Trang 7

And change it to:

myResult = vbOK

3 Save the script

4 Put the edited version of the script and the LabelGraphic Support folder inside a folder named “Startup Scripts” in the Scripts folder inside your InDesign folder Create the folder if it does not already exist

End Script

Scripting is all about empowerment Don’t just sit around telling

yourself that the reason you’re working late is that InDesign can’t do something you’d like it to do Sure, there are things in every program we’d like the manufacturer to fix, but, with InDesign’s scripting fea-

tures, we’ve finally got the tools we need to fix them ourselves.

By urging you to take up scripting, we’re urging you to take trol of InDesign, your publications, your work, and your life We know you can do it!

Trang 8

A hundred years ago, when David was a young pup, he turned in a school essay he had typed using an amazing new device called a per-sonal computer and printed on that technological marvel, the dot-matrix printer His teacher was so impressed that she wrote her copi-ous corrections on a separate page, so as not to spoil the appearance

of David’s “professionally published” work Today, a school report

printed on a color laser or inkjet printer is de rigueur, and teachers

may question a student’s work ethic if they don’t have a ing Web site and public relations team

correspond-Communication of data has come a long way, and while print is far from dead, you can bet that the future of publishing isn’t solely a matter of throwing more ink at paper Today’s communicators have

to be adept at creating both print and interactive documents—files that include buttons, sounds, and movies Fortunately, InDesign offers a number of features for the “rich media” producer Many of these tools don’t produce any visible effect on your InDesign pages, but change the behavior of PDF or Flash SWF files that you export

Interactive Documents

Trang 9

Interactive Only After Export

The key thing to understand about InDesign’s interactive features

is that they only work when you export the file to a format that can support them, such as PDF, SWF, or XHTML And, different formats support different features

Acrobat PDF You may not expect that the PDF format has the most

wide range of support for interactive media—at least in terms of what you can export from InDesign However, you should plan on using the Acrobat 6 format (or later) The earlier Acrobat 4 or 5 (that’s PDF version 1.3 and 1.4) formats don’t support some file formats, embed-ding movies in the PDF, CMYK or non-rectangular posters (more

on what posters are later in this chapter), or support for interactive objects on the same page as transparency effects (such as feathering and opacity)

That said, even Acrobat 6, 7, and 8 files don’t support all the media tools you might want For example, there are still a limited number of page turn transitions, and MP3 sound files don’t work Also note that you should use Acrobat Reader or Acrobat Pro to view interactive PDF files—while other PDF readers (such as Preview in Mac OS X) can open them, most of the media features won’t work

rich-Unfortunately, although you can import most flavors of SWF into InDesign (we’ll explain how later in this chapter), when you export a PDF file, Acrobat has significant problems displaying the SWF—even Acrobat 9, which has the Flash Player built in! Therefore,

if you want to add SWF files to your interactive PDF files, we suggest adding them manually in Acrobat Pro, after you have exported the PDF from InDesign We hope that this will be fixed before too long

We cover how to export PDF files in Chapter 7, “Importing and Exporting.”

XHTML and ePub InDesign has very limited support for XHTML

and ePub documents However, hyperlinks that you create in InDesign are exported properly We cover how to export XHTML and epub documents from InDesign in Chapter 7, “Importing and Exporting.”

SWF InDesign can export one or more pages from your document

directly to the SWF (Shockwave Flash) format We’ll discuss this in more detail later in this chapter, but it’s important to note that only buttons, hyperlinks, and page transitions are honored in your final SWF file—imported sounds and movies are stripped out And, in fact, buttons that interact with transparency effects, and some button actions themselves (such as Go to Next View) are also not honored

Trang 10

chapter 13 interactive pdf 717

XFL InDesign’s SWF export is cool for simple projects, but limited

to a few simple effects If you know ActionScript, or you’re working with a Flash developer, you’re going to want to export your InDesign document in the XFL format, which is an interchange format that Flash CS4 Professional can read But again, there are caveats: the XFL format strips out all the interactivity you’ve added in InDesign—so

if you’re heading for XFL, you might as well skip making hyperlinks, buttons, movies, and page transitions

Hyperlinks

What is an interactive page without links? Links help your readers explore your file, jumping between pages, to other documents, or even to Web sites You can also add links to files that your readers can download, and you can add links for sending email PDF files offer three kinds of links: hyperlinks, bookmarks, and buttons Let’s look at each of these in turn

A hyperlink is essentially a button—it’s a “hot” area that performs some action when you click it There are two big differences between

a hyperlink and a button: First, you can apply a hyperlink directly to

a range of text—though behind the scenes, InDesign is still more or less drawing a button around that text Second, you can save a hyper-link destination and use it more than once

To make a hyperlink, you’ll need to open the Hyperlinks panel from the Interactive submenu under the Window menu The Hyper-links panel also includes the Cross-References panel; we discuss cross-references in Chapter 3, “Text.”

Named versus Unnamed Hyperlinks

When you make a hyperlink, you need to decide whether it should be

a hyperlink that can be used multiple times (which InDesign calls a

“Shared Hyperlink Destination”), or a one-off link Because these are similar in concept to named and unnamed color swatches, we tend

to call these named and unnamed hyperlinks

Named hyperlinks are actually easier to make, but they can slow you down if you’re going to make dozens (or hundreds) of them, because each one you add takes a position on the Hyperlink panel’s URL pop-up menu Searching through 100 URLs is a hassle There-

fore, although we tend to eschew unnamed color swatches, we

actu-ally use unnamed hyperlinks most of the time

On the other hand, if you are going to use a hyperlink several times in a document, it’s great to make it named That way, if you

Trang 11

need to edit the link, you can change it once and it gets updated everywhere in the file.

Fast Hyperlinks The fastest way to make a hyperlink is to select some text (with the

Type tool) or a frame (with the Selection tool) and type a Web address into the URL field at the top of the Hyperlinks panel (see Figure 13-1) After you press Return/Enter, you’ll see the link appear in the list in the middle of the Hyperlinks panel

Unfortunately, this method has several significant drawbacks: First, this always creates a named hyperlink; there is no choice here Second, InDesign usually places a big, ugly black rectangle around the text or object Third, you can only make links to URLs (no page links, and other goodies we’ll explain in a minute) Finally, if you selected a frame, the link appears in the panel as something generic, like “Hyperlink.” If you selected some text, the text itself appears in the list, often causing confusion

Editing Hyperlinks If you do want to make a named hyperlink, using the URL field

works fine But immediately after making the link you should edit it First, you can rename any link in the Hyperlinks panel by clicking

on it and choosing Rename Hyperlink from the panel menu If you

do this a lot, make yourself a custom keyboard shortcut

Then, double-click on the link in the Hyperlinks panel to open the Edit Hyperlink dialog box (You can also edit a hyperlink by selecting the text or frame, and choosing Hyperlinks Options from the panel menu.) You have several options

Link To and Destination You can tell InDesign what to link to by

choosing one of the six options in the Link To pop-up menu The first three let you make unnamed or named links; the last is for shared, named links If you have already made a named link with the URL field, you can convert the link to a local link, but the original named link you made still remains in the URL list—we’ll explain how to remove it later in the chapter

▶ URL To target a URL, choose URL from the Link To pop-up

menu and type the address into the Destination URL field A URL is typically a place on the Internet, like an HTTP or FTP site Note, however, that Acrobat or Flash just passes this URL to the default Web browser to deal with

(By the way, if you open a SWF with a hyperlink in it on your local hard drive, the Flash plug-in will likely throw up an alert

Trang 12

chapter 13 interactive pdf 719

saying that there’s a potential security risk This is one of the many insane problems with Flash, in our opinion However, you can avoid the alert by clicking Settings, then telling the Flash settings to always trust your local computer If you place the SWF on the Web, you shouldn’t see the alert.)

▶ File If you want your hyperlink to open another PDF or file on

your disk or on the server, you can choose File from the Link To pop-up menu Unfortunately, Acrobat and Flash also hand these links to your Web browser to open, which is kind of crazy If the browser knows what to do with it, it’ll display it; if not, the file will likely be downloaded To jump from one PDF to another, it’s usually better to use a button, which we discuss in a later section

Figure 13-1 New Named Hyperlink

After selecting text or an object, type any URL here.

By default, the “name” of the hyperlink is the text you have selected.

Double-click the hyperlink

to display the Edit Hyperlink dialog box.

When you change the Link To pop-up menu, you get a different set of options.

Trang 13

▶ Email If you want your link to send you an email, you could

make a URL link that begins with mailto://, but it’s easier to set

the Link To pop-up menu to Email, then fill in the Address and Subject Line fields When the viewer clicks on this kind of link, Acrobat launches your default Web browser and creates a new, addressed email message

▶ Page To link to another page within your document (but not

to specific text or an object on the page), choose Page from the Link To pop-up menu Enter the page number you want to link

to in the Page field and which magnification you want to use

to view that page from the Zoom Setting pop-up menu Most

of the zoom settings (such as Fit Width in Window) are pretty self-explanatory; the only two that we find confusing are Inherit Zoom and Fixed Inherit Zoom leaves the viewer’s magnification setting alone Fixed is supposed to remember the zoom setting

in InDesign when you created the hyperlink destination, but

it only seems to produce the same effect as Inherit Zoom The Zoom Settings are ignored in SWF files

Note that you can also choose a different file from the ment pop-up menu (if you have another InDesign document open) This sounds good, but it doesn’t really work—after all, you’re asking Flash or Acrobat to open your other InDesign file, which it cannot do

Docu-▶ Text Anchor If there is some text you want to target, you should

choose a Text Anchor from the Link To pop-up menu We cuss how to make a text anchor later in this chapter

dis-▶ Shared Destination If you want your hyperlink to point to a

link you have already created as a named link, choose Shared Destination, then choose the link from the Name pop-up menu

Character Style If your hyperlink is on selected text, you can tell

InDesign to apply a character style to it For example, you might want to give the text a light blue underline to indicate to the reader

that this is “clickable.” Very helpful What you can not do is make a

character style that automatically applies a hyperlink We hope to see that in a future version of InDesign

Appearance Remember that a hyperlink is technically a button in

the PDF The Appearance section lets you control how that object appears in the PDF file If you want it to be invisible, set the Type pop-up menu to Invisible Rectangle If you do this, you should be

Trang 14

chapter 13 interactive pdf 721

sure to apply some character style to the text; otherwise, the only way anyone will know that the link is there is that the cursor will change when it moves over it

The other Appearance options are pretty dorky Maybe someday InDesign will offer cooler hyperlink options, such as making the text highlight when you hover over it and then glow or burst into flame when you click it Until then, only buttons provide interesting link effects (see “Buttons,” later in this chapter)

By the way, if you import a Word document that has lots of words surrounded by rectangles, they’re probably hyperlinks You can make all those rectangles disappear quickly by selecting all the hyperlinks in the Hyperlinks panel (click on the first and then Shift-click on the last), choosing Hyperlink Options from the panel menu, and then changing the Type pop-up menu in the Appearance section from Visible Rectangle to Invisible Rectangle

Making a New Unnamed Hyperlink

If you want to bypass making a named hyperlink entirely, select the text or frame and click the Create New Hyperlink button in the Hyperlinks panel (or choose New Hyperlink from the panel menu) This opens the New Hyperlink dialog box, which offers all the same features that we discussed in the last section

Making a New Hyperlink Destination

InDesign also lets you make a named hyperlink without actually applying it to any text or objects Of course, these links won’t do anything, but it might be helpful if you have a list of known destina-tions you’ll be targeting multiple times as you lay out your file To do this, select New Hyperlink Destination from the Hyperlinks panel menu (see Figure 13-2) You can choose from among three types of hyperlink destinations: Page, Text Anchor, and URL

▶ Page After you choose Page from the Type pop-up menu, you

can choose which page and zoom setting to use Now give your Page hyperlink destination a name Or, better yet, turn on the Name with Page Number check box, which names it automati-cally This name is what you’ll later use to apply this hyperlink destination to the text or object on your page

▶ URL The URL hyperlink destination lets you enter two values:

The Web site or mailto address you want to target, and a name for this destination Again, you’ll be using this name later when you create the hyperlink

▶ Text Anchor The Text Anchor option lets you create an anchor

to a specific piece of text in your document Once you have

Trang 15

created a text anchor, you can target it when making a link (which we talked about earlier) To do this, first place the cursor in the destination text (or select one or more characters

hyper-of the text), or else this option will be grayed out Then, in the New Hyperlink Destination dialog box, simply give the anchor a name This is identical to how most HTML authoring programs create text anchors, too

a named hyperlink, select it and click the Delete button

Hyperlinks from URLs in the Text

If you’ve already typed a URL in a text frame and now you want

to make that URL a hyperlink, use the Text tool to select the URL and choose New Hyperlink from URL from the Hyperlinks panel menu This is a two-for-one: InDesign first makes a URL destination (giving it the same name as the URL itself), and then applies that

Figure 13-2 Creating a New

Hyperlink Destination

Use the Type pop-up menu to select the type of hyperlink destination you want to create.

Ngày đăng: 01/07/2014, 13:20

TỪ KHÓA LIÊN QUAN