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.




PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Quick PDF Library

Get products to market faster with this amazing PDF developer SDK. Over 900 functions and an equally...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.