Create a Book Packager using ExtendscriptFriday, July 15 2011 @ 10:30 AM, By anarora
You all must be familiar with the great power that lies in Extendscript. With the scripting support in FrameMaker 10 you can easily automate time-consuming and repetitive tasks.
Archive or Packager, that I am going to describe here, is one such utility developed using FrameMaker scripting support.
Description: It copies a book to a target folder, given by the user, and gathers all the assets for that book and its chapters into this archive directory. All references in the documents are then made to point to these files. Once a book has been archived, you can zip the directory to create a compressed self-contained archive of your book. It handles all components of hierarchical books i.e. Folders, Groups, Folder Templates and Nested books. Works on structured and unstructured documents as well.
Components that are archived:
- Book Chapters
- Referenced Graphics, multimedia and flash content
- Poster files applied on multimedia
- External cross-references
- Text insets
- Open the book or document you want to archive.
- Choose File-> Script-> Run and select the script Archive.jsx. This will create a new menu item Archive.
- Choose the menu command:
File > Utilities > Archive Book (if a book file is active)
File > Utilities > Archive Document (if a document file is active)
1. Creates a menu Archive inside the File->Utility menu
var bookMenu = app.GetNamedMenu(“BookUtilitiesMenu”);
var newCmd=DefineCommand(1,”Archive” ,”Archive”,”");
2. It opens the Browse Folder dialog where the user can select the folder to be used to Archive his files. He can also create a new folder. In the directory you choose, the Archive plugin will create a subdirectory “Insets” to hold the referenced graphics and text insets
folderPath= ChooseFile(“Select Archive Folder”,”",”",Constants.FV_ChooseOpenDir,”");
insetPath = folderPath.concat(“\\”,”Insets”);
newFolder=new Folder (insetPath);
3. It silently opens all the chapter files in the book, finds all the referenced files in those files, copies all referenced files to Insets folder, changes the document references, saves them , and silently closes all the files. The book, with the new component paths, is then saved at the Archive directory.
//copy inset to the new folder
var fullPath=getNewPathForInsets(oldPath);//user-defined function that creates new paths for the insets
4. At the end of operation it gives an Alert informing the user about the completion of the operation and the archived location.
Alert(“Your achive is ready at \n” + folderPath ,Constants.FF_ALERT_CONTINUE_NOTE);
For further details see the attached script.
You can develop and use such similar utilities to eliminate manual effort and increase productivity. Do try the script and let us know your valuable feedback!
With best regards,
Adobe FrameMaker Engineering Team