Tài liệu InDesign CS5 Bible- P18 pptx

50 309 0
Tài liệu InDesign CS5 Bible- P18 pptx

Đ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

Chapter 36: Working with XML 805 Exporting XML Files When the InDesign document has the proper elements properly tagged to the document’s content, you’re ready to export it to an XML file for use by a Web site’s content management system or other XML database. Choose File ➪ Export or press Ô+E or Ctrl+E to open the Export dialog box. In this dialog box, give the XML file a name in the Save As field (InDesign automatically adds the file name extension .xml ), select a folder in which to place the file, and — most important — choose XML from the Format popup menu (on the Mac) or Save as Type popup menu (in Windows). Then click Save. The Export XML dialog box appears. It opens with the General pane. This pane is simple: l Include DTD Declaration: Select this check box to include the DTD information in the exported file. Otherwise, the XML database needs to import the DTD file separately. l View XML Using: Select this check box and select a Web browser or Web-supporting application in the adjacent popup menu to preview the XML file in that browser or program. l Export from Selected Element: If an element is selected in the Structure pane, the Export from Selected Element check box is available; if it’s selected, it exports the XML file only from that element on. l Export Untagged Tables as CALS XML: To convert InDesign tables not tagged with XML attributes to the CALS XML format, select this check box. l Remap Break, Whitespace, and Special Characters: To convert special characters to their XML codes, select this check box. l Apply XSLT: If this check box is selected, InDesign applies the XSLT style sheet either from the XML file or from a separate file; you specify which by using the popup menu to its right. l Encoding: Use this popup menu to choose the text encoding mechanism — a way of representing international characters across different computer systems. Your content engineer or Webmaster will tell you whether to select UTF-8, UTF-16, or Shift-JIS. In the Graphics pane, you tell InDesign how to handle the output of any tagged pictures. Your options are as follows: l Image Options section: Here, you indicate what images to copy to the Images subfolder that InDesign creates. Your choices are Original Images, Optimized Original Images, and Optimized Formatted Images. You can select any or all of these. The optimized images are converted to GIF or JPEG for use on the Web unless you specify GIF or JPEG in the Image Conversion popup menu rather than leave the default setting of Automatic; the formatted images crop the images to reduce file size. l GIF Options section: Here, you choose the color palette in the Palette popup menu, with choices of Adaptive (No Dither), Web, System (Mac), and System (Win). Ask your Webmaster what to use; usually, you select Adaptive (No Dither). For very large images, 50_607169-ch36.indd 80550_607169-ch36.indd 805 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Part IX: Programming InDesign 806 interlacing can make on-screen display over the Web seem faster (by building the image line by line rather than waiting until the whole image has been transferred to the browser before anything appears); if you want to have such interlaced display of GIF files, select the Interlace option. l JPEG Options section: Here, you have options similar to those for GIF files. In the Image Quality popup menu, choose the desired image quality (Low, Medium, High, and Maximum). In the Format Method, choose Progressive to have the file displayed progres- sively (similar to the interlace option for GIF files) or Baseline to display it all at one time. Unless your images are very large, keep the default Baseline. When you export an XML file with graphics, InDesign automatically embeds XMP media manage- ment properties with the graphics’ tags. You can view those properties by choosing File ➪ File Info or pressing Option+Shift+Ô+I or Ctrl+Alt+Shift+I and then choosing the Advanced pane. This information may be of interest to your content engineer but has no real meaning for the page designer. However, the content engineer may want to fill out the information in the File Info dialog box’s other panes — Description and Origin — into which you can add comments, creator infor- mation and contact details, copyright information, credit and source information, keywords, and copyright URLs. Exporting to IDML Another way to export to XML format is by using the InDesign Markup Language (IDML) format. IDML is based on XML, so developers can work on InDesign layouts without needing InDesign. Note that IDML is not exactly XML, so only IDML-aware programs can use the IDML format; these are typically special apps or plug-ins to XML-aware apps meant to work specifically with InDesign files. For example, a company might add IDML capabilities to a catalog publishing system so that it can generate InDesign files directly from its catalog databases. Cross-Reference IDML is also the format used to save an InDesign CS5 layout in a format that InDesign CS4 can open, as Chapter 4 explains. n By using XML as the IDML file format’s basis, all of InDesign’s capabilities and content attributes are available to developers for, for example, layout automation, database publishing, and content management system applications. This supplements InDesign’s existing ability to expose all its internal XML capabilities via scripting, so other XML- and script-aware apps can work with InDesign directly. Note that none of this affects the designer using InDesign in terms of using InDesign itself. You export an InDesign layout to IDML format by choosing InDesign Markup (IDML) in the Format popup menu (on the Mac) or Save as Type popup menu (in Windows) in the Export dialog box (choose File ➪ Export or press Ô+E or Ctrl+E). There are no options; InDesign just creates the IDML file when you click Save. 50_607169-ch36.indd 80650_607169-ch36.indd 806 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Chapter 36: Working with XML 807 Summary InDesign lets you tag content within documents with XML tags, so you can transfer that content to an XML database or Web content engine from which it can be used in a variety of media, format- ted as appropriate for each. You can also import XML content into InDesign, automatically placing content into the appropriate frames if you’ve created an appropriate template and tagged it with the right XML tags. But InDesign’s XML tools are only the beginning — you need an XML database and content-creation and content-presentation tools to use the XML data derived from InDesign documents. For organizations creating complex content creation and management workflows using XML, InDesign exposes all of its functionality as XML rules that can be scripted, essentially letting you flexibly control the creation of InDesign files based on XML programming and XML data attributes. It also has the new InDesign Markup Language (IDML) file format that is based on XML, so devel- opers can create and work with InDesign-compatible files in their own apps, using XML as the standard description for any elements they work with across apps. 50_607169-ch36.indd 80750_607169-ch36.indd 807 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 50_607169-ch36.indd 80850_607169-ch36.indd 808 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 809 CHAPTER Using Scripts IN THIS CHAPTER Installing and accessing scripts Exploring JavaScript Exploring AppleScript Exploring VBA Writing scripts Learning more about scripting S cripting automates many features in InDesign — it’s essentially a way to program InDesign to do specific actions. Because InDesign uses standard script languages, you can also run scripts that work with multiple programs in concert, including InDesign. (All the applications must support the same scripting language, of course.) For example, you might use scripts to automate database publishing, such as to run a database search, export data to a text file, import that file into InDesign, and then apply the appropriate formatting. InDesign supports three scripting languages: l JavaScript on both Mac and Windows l AppleScript on the Mac only l Visual Basic for Applications (VBA) on Windows only Because only JavaScript is supported by both platforms, I recommend you use it wherever possible so that your scripts can work in cross-platform envi- ronments. InDesign doesn’t force you to choose just one scripting language, so you could keep using old AppleScript or VBA scripts created for previous versions of InDesign, as well as new scripts written in JavaScript. As you become comfortable with scriptwriting, you’re also likely to discover that virtually everything you do with InDesign is a repetitive task. The more you can free yourself of this kind of work by using scripts, the more time you have to be creative. The possibilities are endless. But before you get too excited, remember that scripting is programming, so most layout artists stay clear of it, using scripts only if they have a programmer available to write them. 51_607169-ch37.indd 80951_607169-ch37.indd 809 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Part IX: Programming InDesign 810 Using Scripts Accessing scripts is easy; they show up in the Scripts panel (choose Window ➪ Utilities ➪ Scripts or press Option+Ô+F11 or Ctrl+Alt+F11) if you’ve placed scripts in the Scripts folder inside the folder that contains the InDesign application, as shown in Figure 37.1. Scripts don’t have to be in the Scripts folder — they can be anywhere on your computer — but to use them outside this folder means you have to double-click them from your desktop rather than have access from within InDesign. FIGURE 37.1 The Scripts panel in InDesign and its flyout menu Script tips When writing scripts, you can associate a script to a specific InDesign menu action so that when a user chooses that menu item, a script runs automatically (technically, by assigning a script to a MenuAction command’s Prenotify or Postnotify property when writing the script’s code). In InDesign, be sure that Enable Attached Scripts is also enabled in the Scripts panel’s flyout menu. When running scripts, keep the following tips in mind: l You can undo all of a script’s action by using the InDesign Undo command (choose Edit ➪ Undo or press Ô+Z or Ctrl+Z) by ensuring that Undo Affects Entire Script is enabled in the Scripts panel’s flyout menu. Otherwise, the undo command reverses just the last action within the script, requiring you to undo several times to roll back the com- plete script action. l By enabling the Enable Redraw flyout menu option in the Scripts panel, you can force InDesign to redraw the display while a script is running. This ensures that any changes to the document are immediately visible. New Feature You can now access InDesign’s Tools panel and its tools via scripts in InDesign CS5. n 51_607169-ch37.indd 81051_607169-ch37.indd 810 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Chapter 37: Using Scripts 811 Script locations Whether you create your own scripts or get them from vendors or other users, you need to save them so that InDesign knows they exist. You have a choice of two locations: l The Scripts folder inside the InDesign application folder. You can usually find it as Applications:Adobe InDesign CS5:Scripts in Mac OS X, and Program Files\Adobe\InDesign CS5\Scripts in Windows. This makes the script available to all users of your computer. If you want the script to start when InDesign launches, place it in the Startup Scripts subfolder. l The Script Panel folder. This makes the script available only to that specific user (note that it will appear in a folder called User in your Scripts panel). The path varies based on your operating system: l On the Mac, the path is Users: username :Library:Preferences:Adobe InDesign:Version 7.0:en_US:Scripts:Scripts Panel . l In Windows XP, the path is Documents and Settings\ username \Application Data\Adobe\InDesign\Version 7.0\en_US\Scripts\Scripts Panel . l In Windows Vista, the path is Users\ username \AppData\Roaming\Adobe\ InDesign\Version 7.0\en_US\Scripts\Scripts Panel . l In Windows 7, the path is Users\ username \AppData\Roaming\Adobe\ InDesign\Version 7.0\en_US\Scripts\Scripts Panel . The script shows up in the Scripts panel. If it doesn’t show up immediately, quit and reopen InDesign. Tip To use scripts developed for InDesign CS4, create a new folder called Version 6.0 Scripts inside the Scripts or Script Panel folder and move your old scripts there. Likewise, scripts developed for InDesign CS3 should be placed in a folder called Version 5.0 Scripts . These scripts then work in InDesign CS5. n Scripting principles No matter what scripting language you use, there are several basic principles to observe. These fall into four basic categories: l Grammar: All languages — including programming languages such as Pascal and C++, as well as scripting languages — include grammatical components that are used in standard- ized sequences. In English, we combine nouns, verbs, adjectives, adverbs, and so on to create sentences. Everybody knows the meaning of “The weather is especially nice today,” because it uses common words in a sequence that makes sense. The sentence “Nice is the especially today weather” has the right components but it’s arranged in the wrong sequence, so the meaning is lost. 51_607169-ch37.indd 81151_607169-ch37.indd 811 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Part IX: Programming InDesign 812 l Statements and syntax rules: In JavaScript, AppleScript, and VBA, verbs, nouns, adjec- tives, and prepositions are combined to create statements; statements are combined to form scripts. Verbs are also called commands and methods; nouns are called objects; and adjectives are called properties. Syntax rules specify how statements and scripts must be constructed so that a computer can understand them. l Object hierarchy: All three scripting languages use a structural element called an object hierarchy. It’s a fancy term for a simple concept. An object hierarchy works like a set of boxes within boxes. A large box contains a smaller box, which contains a smaller box, which contains a smaller box, and so on, until you reach the smallest box, which contains nothing and is the final level in the hierarchy of boxes. l InDesign hierarchy: InDesign contains its own hierarchy, which lends itself nicely to scripting. A document contains pages, pages contain frames, and frames contain text and pictures. You can create scripts that perform actions at any of these levels. In other words, with scripts you can create documents, add pages, add items to pages, and modify the contents of frames, right down to a particular character in a text frame. You can think of this hierarchy in InDesign as a chain of command. You can’t talk directly to an item that’s at the bottom of the chain. Rather, you must first address the top level, and then the next, and so on, until you’ve reached the item at the bottom of the chain. This is analogous to the way you use InDesign: You create new documents, add pages, place text and graphics on the pages, and, finally, modify the contents of the frames containing those items. If you’re thinking about dabbling with any of the scripting languages supported by InDesign, the following words of both caution and encouragement are in order. First the encouragement: You don’t necessarily need programming experience, scripting experience, or a pocket protector to begin creating scripts. A bit of curiosity and a touch of patience will suffice. Now the caution: Scripting is essentially a euphemism for programming (that is, figuring out the right commands and then typing them for the application to execute). Writing scripts isn’t a matter of choosing commands from menus, and clicking and dragging them, or entering values into fields; nor is it like writing a limerick. If you’re starting from scratch, know in advance that you have to learn some new skills. Learning to create scripts is like learning to swim: You can read books, documentation, and articles until your head spins, but eventually you have to get a little wet. The best way to learn about scripting is to write a script. So put on your swimsuit and dive in. Be forewarned: There’s something almost narcotic about creating scripts, and it’s not uncommon for novice scriptwriters to get hooked. Don’t be surprised if what starts out to be a 15-minute look- see turns into a multihour, late-night programming episode. Note Because scripting languages differ, you can’t always duplicate the functionality of a specific script in one lan- guage into a script written in a different language. n 51_607169-ch37.indd 81251_607169-ch37.indd 812 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Chapter 37: Using Scripts 813 Note Adobe has a nearly 2,000-page scripting guide available as a PDF file. It comes with your InDesign or Creative Suite software, residing on the installation DVD. You can find additional resources at www.adobe.com . n Exploring JavaScript JavaScript is a scripting language developed by Netscape Communications, based on Sun Microsystems’s Java language that was meant to let Web browsers manage resources on far-flung servers by running scripts to control the servers from a desktop. JavaScript soon became a popular scripting language because, as does Java, it runs on so many types of computers, including Windows, Mac, and Unix. But because it is based largely on the object-oriented approach taken by professional computer languages such as C and C++, it can be difficult for nonprogrammers to use. There are lots of JavaScript editor programs available. Most of these are developed by individuals and small firms, so the list is always changing. I recommend you use the Google search engine ( www.google.com ) and search for JavaScript editor to find the most current programs. A great script-editing program for Mac users is Bare Bones Software’s venerable BBEdit; you can get more information at www.barebones.com . Learning the language JavaScript is a very complex language based on object-oriented programming, which abstracts items and attributes as objects that are then grouped, changed, or otherwise manipulated. This means that JavaScript is less English-like than other scripting languages because it requires you to spend a fair amount of time setting up the objects before you can manipulate them. myObject.strokeTint = newValue; This example shows that there is a current object named strokeTint being set to a new value; the actual value for newValue is set earlier in the script. What you need to write and run scripts You need a program that can display, edit, and test your JavaScript; there is no bundled JavaScript editor in Windows or Mac OS X. Such editors typically format the JavaScript code for you, indent- ing it automatically, graying out comments, and highlighting certain keywords. You can use a word processor or text editor to write and edit scripts, but such programs can’t check the syntax or automatically format the script text to help show nested loops, conditional branches, and so on. Also, you can usually use an HTML editor such as Adobe Dreamweaver in which to edit JavaScripts, though they also typically don’t provide any debugging tools to help you track and fix coding (syntax) errors. (Figure 37.2 shows a JavaScript script being edited in Dreamweaver.) In this case, you need to open the error window in your browser as you test the code and see if it identifies the error location to help you find it in your HTML editor. 51_607169-ch37.indd 81351_607169-ch37.indd 813 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Part IX: Programming InDesign 814 FIGURE 37.2 A JavaScript program viewed in Adobe Dreamweaver Running your script The easiest way to run a script is to double-click it in the Scripts panel within InDesign, but you also can simply double-click the script file; note that InDesign may need to be open. Also, while you’re developing the script, you can run the script directly from the application in which you created it — again, InDesign may need to be open. If you’ve done everything correctly, you see Before you venture too far into scripting, you should review the JavaScript-related information provided with InDesign: l JavaScript documentation and tools: Sun places the very technical JavaScript documentation on its Web site at http://java.sun.com/javascript/index.jsp . l InDesign scripting documentation: The InDesign installation DVD contains a 2,000-plus- page PDF file that explains scripting for InDesign. This document, although a bit on the tech- nical side, is a valuable resource. It includes an overview of JavaScript scripting and the object model, as well as a list of InDesign-specific scripting terms and scripting examples. If you want still more information about JavaScript, several books are available, including Beginning JavaScript, Fourth Edition, by Paul Wilton and Jeremy McPeak and JavaScript Bible, Seventh Edition, by Danny Goodman et al. (both from Wiley Publishing). Getting More Information on JavaScript 51_607169-ch37.indd 81451_607169-ch37.indd 814 4/22/10 8:09 PM4/22/10 8:09 PM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... about making the transition to InDesign CS5 IN THIS APPENDIX Understanding CS5 system requirements Installing InDesign CS5 Upgrading from prior versions of InDesign Removing InDesign Understanding InDesign CS5 System Requirements InDesign CS5 does not require extraordinary resources If you have a Mac or PC that runs one of the required operating systems, you can run InDesign CS5 Just be sure to have enough... script can use only one language) 825 Part X Appendixes IN THIS PART Appendix A Installing InDesign and Extensions Appendix B What’s New in InDesign CS5 APPENDIX Installing InDesign and Extensions I nstalling InDesign CS5 is surprisingly easy, but before installing or upgrading, make sure your system meets the InDesign CS5 system requirements Then use the steps in this appendix to make quick work of the... fact that InDesign CS5 requires a new installation is that InDesign CS5 doesn’t have any of the custom settings you’ve selected in your earlier version of InDesign; you often don’t realize how many preferences you’ve set over time until you switch to a new version of the software If you did put some effort into customizing your previous version of InDesign, when you start using InDesign CS5, do the... for itself It might use InDesign CS5 or simply InDesign (yes, the name may include the registered trademark symbol) If you run a script from AppleScript (instead of just double-clicking it) and AppleScript can’t find InDesign, it gives you a dialog box with which you find the InDesign program When you’ve found and selected the InDesign application, AppleScript finds out what InDesign s file name is... complete, click Done Managing Extension Software InDesign lets you add plug-in software (now called extensions) to add new capabilities There are dozens of such extensions available from a variety of vendors; go to www.InDesignCentral com for a current list Note Plug-ins designed for earlier versions of InDesign do not work in InDesign CS5 n New Feature InDesign CS5 has significantly changed how extensions... can get fancy by combining all the set statements into a single script so that you can use the script to make all the changes at one time VBA Dim myInDesign As InDesign. Application Set myInDesign = CreateObject( "InDesign. Application .CS5" ) Set mySelection = myInDesign.Selection If TypeName(mySelection.Item(1)) = "EPS" Then mySelection.Parent.RotationAngle = 30 Else mySelection.RotationAngle = 30 End If... myNumberOfDocuments to (count documents) if myNumberOfDocuments = 0 then display dialog "No InDesign publications are open!" end if end tell VBA Dim myInDesign as InDesign. Application Set myInDesign = CreateObject ( "InDesign. Application.CS4") If myInDesign.Documents.Count MsgBox "No InDesign publications are open!" End If End Sub Another form of conditional is what’s called a control loop, in which an action occurs... functional divisions InDesign Interface The basic user interface — the iconography, panel design, window management, and so on — in InDesign CS5 is essentially the same as in InDesign CS4, but InDesign brings in several new tools and reworks the operations of some panels both to handle new capabilities and to streamline the operations of existing capabilities 837 IN THIS APPENDIX Changes to the InDesign interface... Appendixes Installation and basic components InDesign CS5 does not support Mac OS X 10.4 Tiger, nor does it support Macs using the PowerPC processor or Macs using single-core Intel chips In practice, any iMac, Mac Mini, MacBook, MacBook Pro, MacBook Air, or Mac Pro produced in 2006 or later can run InDesign CS5 except the first (early 2006) edition of the Mac Mini InDesign CS5 has changed the sequence of installation... subscription-based CS Live services from within Creative Suite applications The Required folder used in previous versions of InDesign to store the software components used by InDesign does not exist in InDesign CS5 Instead, the Plug-ins folder now contains all required components of InDesign CS5 The optional and third-party plug-ins — now called extensions — are now managed by the Adobe Extension Manager application . time. VBA Dim myInDesign As InDesign. Application Set myInDesign = CreateObject(" ;InDesign. Application .CS5& quot;) Set mySelection = myInDesign.Selection. myInDesign as InDesign. Application Set myInDesign = CreateObject (" ;InDesign. Application.CS4") If myInDesign.Documents.Count MsgBox "No InDesign

Ngày đăng: 24/12/2013, 15:16

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan