|
In modern versions of IDL (and as far back as IDL 5.2) encapsulated postscript files can be output with previews in both the EPSI and EPSF standardized formats. (Before IDL 5.2, previews were only available in the EPSI format.) The format used for previews is specified with the PREVIEW keyword to the DEVICE routine:
PREVIEW=0 : do not include a preview (DEFAULT) PREVIEW=1 : EPSI format (ASCII) PREVIEW=2 : EPSF format (ASCII w/ binary header)
For example, the following set of IDL commands can be executed to create an encapsulated postscript file in EPSF format with a preview:
IDL> currdevice=!D.NAME IDL> set_plot,'ps' IDL> device,filename='preview_2.eps',/encapsulated,preview=2,xsize=4,ysize=2,/inches IDL> plot,indgen(10) IDL> device,/close IDL> set_plot,currdevice
|
|
Despite the fact that EPSI (PREVIEW=1) is documented as the platform independent format, it is not widely supported in the Windows/DOS domain (including Microsoft applications). Consequently, if you import an .eps file created in IDL with PREVIEW=1 into an application like Microsoft Word you will not see the preview. Instead, Microsoft Word inserts a placeholder which looks like:
 Even though MSWord is telling you that "This EPS picture was not saved with a preview included in it", the EPSI file output by IDL in fact DOES have a viable preview. Microsoft's application simply cannot handle the import of the preview in EPSI format. There is absolutely nothing wrong with the .eps files that IDL outputs, and this can be illustrated if you simply send the Word document with the .eps file inserted in it to a postscript printer (it prints fine !).
The other preview form is known as EPSF (PREVIEW=2), which is a 30 byte (binary) header on the front of the ASCII EPS which points to the EPS and to an additional preview representation. A very common format for this preview is TIFF. Modern versions of IDL can generate DOS format EPSF files that contain the preview in TIFF format, which is a Baseline Bilevel Image with no compression. This form can be imported by many Windows applications, including MSWord. One caveat, however, is that an EPSF file is not entirely ASCII, so it cannot be sent directly to a Postscript printer (unlike the EPSI format). EPSF files must be imported into an application before printing!
Microsoft Word will insert the crude rasterized (TIFF) preview of an encapsulated postscript file created in IDL with PREVIEW=2. However, MS Word normalizes the dimensions of this preview to a 1.778" x 1.778" square. No matter what XSIZE and YSIZE you specify in a call to the DEVICE routine within IDL, MS Word will always normalize the dimensions of the preview to 128 pixels x 128 pixels. For instance, here is the EPSF file which results from the example code given above ("preview_2.eps"):
 In IDL 5.4 three new keywords to the DEVICE routine for the PS device were added which give the user the capability to explicitly control the size and quality of the encapsulated postscript preview, thereby forcing MS Word to insert the graphic with the appropriate scaling and eliminating the aforementioned normalization. These keywords are:
DEVICE Procedure: Keyword Description PRE_DEPTH (PS) Set this keyword to a value indicating the bit depth to be used for the preview in the PostScript file. Valid values are 1 (for black and white preview) and 8 (for 8-bit grayscale preview). This keyword applies only if the PREVIEW keyword is nonzero. The default depth is 8. PRE_XSIZE (PS) Set this keyword to the width to be used for the preview in the PostScript file. This keyword applies only if the PREVIEW keyword value is nonzero. The width is measured in units of centimeters unless the INCHES keyword is set. The default is 1.77778. PRE_YSIZE (PS) Set this keyword to the height to be used for the preview in the PostScript file. This keyword applies only if the PREVIEW keyword value is nonzero. The height is measured in units of centimeters unless the INCHES keyword is set. The default is 1.77778. Here's an example of these keywords in action:
IDL5.4>currdevice=!D.NAME IDL>set_plot,'ps' IDL>device,filename='4x2_line.eps',/encapsulated,preview=2,xsize=4,ysize=2,/inches,$ pre_depth=1,pre_xsize=4,pre_ysize=2 IDL>plot,indgen(10) IDL>device,/close IDL>device,filename='2x2_dist.eps',/encapsulated,preview=2,xsize=2,ysize=2,/inches,$ bits_per_pixel=8,pre_depth=8,pre_xsize=2,pre_ysize=2 IDL>tvscl,dist(144) IDL>device,/close IDL>set_plot,currdevice And here is the result of importing these two EPS files into MS Word:
 The MS Word document pictured above called 'EPS_Quality.doc' can be downloaded by clicking on the following link: Download 'EPS_Quality.doc'
WARNING : The fact that the graphics inserted into the MS Word document are encapsulated postscript means that you have to print this document on a postscript printer via the appropriate postscript printer driver !!! You can print this document to other printers (e.g. PCL) but only the previews themselves will be printed... which means you will end up seeing the crude rasterized TIFF instead of the actual high-quality postscript on your hardcopy output. The only exception to this functionality is that .eps files created in IDL 5.2 with PREVIEW=2 will not import into MS Word, but this was fixed in IDL 5.2.1.
The fact that IDL exports a viable preview with correct dimensions for both the EPSI (PREVIEW=1) and EPSF (PREVIEW=2) formats without using the PRE_* keywords in IDL can be verified using Adobe's FrameMaker. The following IDL code was used to create 2 files ('preview_1.eps' and 'preview_2.eps') in IDL:
IDL> x=indgen(20) IDL> y=x^2 IDL> currdevice=!D.NAME IDL> set_plot,'ps' IDL> device,filename='preview_1.eps',/encapsulated,preview=1,bits_per_pixel=8,xsize=4,ysize=2,/inches IDL> plot,x,y IDL> device,/close IDL> device,filename='preview_2.eps',/encapsulated,preview=2,bits_per_pixel=8,,xsize=4,ysize=2,/inches IDL> plot,x,y IDL> device,/close IDL> set_plot,currdevice When these 2 files are imported into FrameMaker using File > Import > File, the Adobe application successfully recognizes the encapsulated postscript previews with the appropriate scaling which IDL has created :
|