Coyote's Guide to IDL Programming

Including PostScript Graphics in Documents

QUESTION: Can I include IDL PostScript graphics in other documents?

ANSWER: Yes, you can include IDL PostScript graphics in other documents. But if you want to "see" the PostScript graphics you include in other documents, you have a bit more trouble in IDL.

PostScript files that are to be included in other PostScript files are called "encapsulated PostScript" files. IDL is capable of creating encapsulated PostScript output. You must set the ENCAPSULATED keyword to the DEVICE command like this:


However, if you include or import these encapsulated PostScript files into your word processor document, you will not see an image or graphic in your document. What you are likely to see is a grayed-out box. If you print this document, however, you will see the IDL graphic printed in full resolution in the proper imported location.

Note that once you switch to encapsulated PostScript output, all subsequent graphics commands are sent to an encapsulated PostScript file. To switch back to normal PostScript output, you must set the ENCAPSULATED keyword to 0, like this:


Seeing the Imported Graphic

Many people, however, would like to "see" the graphic they are trying to print. To accommodate these people Adobe Systems developed a type of encapsulated PostScript called "Encapsulated PostScript Interchange" format, or EPSI. You can think of an EPSI formatted file as one of those cold capsules that is half cold medicine and half sinus relief. That is, a EPSI file has a "PostScript" portion that gets printed, and a "display" portion that gets displayed on your monitor. In many EPSI files the display portion is a BM or TIFF or PICT type of display, depending upon the type of computer you are using.

In IDL you can create a EPSI file by setting the PREVIEW keyword to the DEVICE command, like this:


But what gets written into the "display" portion of the file is a low-level bitmap of the IDL graphic. These files print in high-resolution PostScript, but display the low-resolution bitmap on the display.

In my experience, these low-resolution bitmaps never show up very well, and certainly not on PCs or Macintoshes. It depends a little bit on what kind of word processing software you are using. Microsoft Word (at least on my Macintosh) doesn't have a clue. Framemaker is better, but the preview image is still mostly unusable.

One way to "see" encapsulated IDL PostScript files is to get the shareware program GhostScript. Versions of GhostScript exist for all machine platforms, although not all versions have the same capabilities. They all can display encapsulated and non-encapsulated PostScript output. On all platforms except Macintosh, the PostScript file can be printed from within GhostScript. (I use the freeware application Drop*PS from Bare Bones Software to print IDL PostScript files on my Macintosh. You can also use the LaserWriter Utility program that comes with the Macintosh system software to print IDL PostScript files.)

For more information about GhostScript, you can look at the GhostScript FAQ page at the University of Wisconsin.

The Macintosh port of GhostScript is also available.

You can contact Bare Bones Software via e-mail at for more information about the Macintosh freeware application Drop*PS.

Web Coyote's Guide to IDL Programming