PDF In-Depth

Moonshine2: The art of Scripting to make your own Distillery

About the Author
 

Nick Hodge

Nick Hodge is the Channel Sales Manager for Adobe Systems, Pacific. Nick's team is responsible for Adobe's distributor and retail partners. The Technical side involves providing customer presentations, indepth training sessions, consulting and troubleshooting: encompassing...  More


 

 
 

Moonshine: This name is a slight play on the theme of "the distiller" -- arguably the engine of Acrobat since version 1.0. The piece of magic that converts reverse-polish-notation, stack-based Postscript to PDF -- Moonshine just seemed like a logical extension of the name.

Learning JavaScript has been a "back-burner" project of mine in recent years. Updating my "Moonshine" scripts for Photoshop was a perfect first project.

Support for PDF across Adobe applications is extensive. Saving out of Illustrator, InDesign through to rendering PDF into bitmaps in Photoshop: PDF is a well-supported exchange format between Adobe applications.

Rather than using Actions, which are step-by-step automation of serial processes, scripts provide a deeper level of control and conditionality; branching if a condition occurs. New in Photoshop CS is the ability to create user-interface elements to further customize the executed actions.

Additionally, scripting Adobe applications has changed in recent versions. Acrobat's JavaScript support is extensive and well documented. After InDesign 1.0, Illustrator 9 and Photoshop 7 increased platform scripting support (Visual Basic/VBScript on Windows and AppleScript on MacOS) -- in the CS versions a cross-platform JavaScript engine is available. There is even a full JavaScript debugger in Photoshop. Doesn't quite compare to the elegance of the Healing Brush or History Brush -- but for scripters, it's a godsend. No more faith-based programming.

Originally written as a proof-of-concept for an Advertising agency in Australia, this script was designed to use the PDF rendering engine of Photoshop to generate JPEGs for web-site publication and client review. Rather than re-generate smaller PDFs, the original Moonshine asked Photoshop to open the PDFs, and render a JPEG from the first page. Moonshine2 updates this to work with Photoshop CS's JavaScript engine.

Installing the Script:

Using the JavaScript scripting engine in Photoshop, this script opens PDFs from a directory and saves them as JPEG.

The Moonshine2.zip file has two contents:

Moonshine2.js

Install this file into the folder "Scripts" inside the "Presets" wherever Photoshop CS is installed on your Mac or PC.

After restarting Photoshop, this script will appear under the "File > Scripts..." menu. Keyboard shortcuts (Edit > Keyboard Shortcuts) can be assigned to scripts, integrating them into the Photoshop application.

MoonshineStart.vbs: (optional)

This script can "live" anywhere on your PC; its function is to launch the script from the Windows shell environment. Please note the line underneath the text in all-caps: you may need to set the path to the script accurately.

Launching and Using Moonshine2

Select Moonshine2 from the File > Scripts menu.

This is alt text

The first dialog asks for the source folder/directory. This is where the "watched" folders reside.

This is alt text

Note: Watched Folders, sometimes known as Hot Folders, is a feature added to Distiller in version 3 and only found in the Professional versions of Acrobat 6 and 7. By monitoring a particular folder, the Distiller starts the PDF generation process once a Postscript file or Encapsulated Postscript File is dropped into the "in". Once processed, the completed PDF (and the processed Postscript file) is placed into an "out" folder. For more information, read "Watching Folders" in Applying Custom Distiller Settings

The second dialog asks questions as to the:

This is alt text

  • dots-per-inch (DPI) of the JPEGs Moonshine2 will create. For web-based images, a resolution of 72 DPI (the default) is OK.
  • width of JPEGs: the width in pixels is the scale the PDFs will be rasterized to when opened by Moonshine2. PDF, as a scalable format, can be small or as large as you need.
  • quality of the saved JPEG: this slider permits the selection of the saved JPEG. The higher the number, the greater the file size and the quality.
  • Once these values are chosen, Moonshine2 looks in the "In" folder for PDFs
  • Opens them at the width and resolution as requested
  • Saves the resulting JPEGs, with the same file name but different file extension, into the :"Out" folder
  • Moves the PDF into the "done" folder

When launched from the MoonshineStart.vbs script, the path is set depending on where the script is installed on your computer. Default values are passed into the Moonshine2.js from variables as defined at the top of the VBscript file.




Related Products at PDF Store

ARTS PDF Crackerjack

Impose pages, automate your workflow, verify certified PDFs, print accurate colour separations, conv... View full product details
Download free demo

PDFlib TET

Reliably extract text from any PDF file with this library/component. TET makes available the text co... View full product details
Download free demo

Nitro PDF Professional

Nitro PDF Professional, your PDF creation and editing product. Priced at $99, Nitro PDF Pro is the m... View full product details
Download free demo

PDF In-Depth Free Product Trials Ubiquitous PDF

Nitro PDF Professional

the perfect PDF product for business and enterprise, combining an extremely competitive price with a...

Download free demo

XpdfViewer

This ActiveX control (OCX) provides a PDF file viewer component, enabling developers to add PDF viewing...

Download free demo

Ubiquitous PDF: PDF eBooks-Library

If you are looking for a good store of PDF content, you could do a lot worse than visiting eBooks-Library.com...

September 03, 2009
Search Planet PDF
more searching options...







Convert PDF Files

Planet PDF Newsletter
Most Popluar Articles
Features

How to Create Slide Shows and Self-running Kiosks in Acrobat

In this tutorial, Ted Padova and Wendy Halderman explain how to best use the features of Acrobat 6 Professional to create a self-running multi-media kiosk for use with displays such as tradeshow exhibits.

Featured Product

ARTS PDF Aerialist

The ultimate plug-in for Adobe Acrobat and #1 selling product at PDF Store. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Platinum Sponsor
Create & Edit PDF - Nitro PDF Software

ARTS PDF

Silver Sponsors

PDF-Tools enfocus

QuickPDF: The Unrivaled PDF Developer Toolkit