Encapsulated PostScript


What is Encapsulated PostScript?

At some point, you may want to include some nice PostScript image into a document. There are a number of problems associated with this, but the main one is that your page layout program needs to know how big the image is, and how to move it to the correct place on the page. Encapsulated PostScript (EPS) is that part of Adobe's Document Structuring Convention that provides this information.

What Is the Document Structuring Convention?

The DSC is a special file format for PostScript documents. The full details for the DSC can (and should) be gotten from Adobe. If you are writing a PostScript printer driver or other utility which will be used by a large number of people to create or manipulate PostScript documents, do not even think about writing it without making it DSC-compliant. You will save yourself and your users a lot of headaches.

Although the full DSC is beyond the scope of this guide, the most basic rules can be explained. A DSC-compliant document is an ordinary PostScript document with a number of comments added. These comments provide information to any postprocessors which work with the files. Some comments strictly provide information, others are used to structure the document into sections, which may be shuffled or processed in other ways by the postprocessor.

Every DSC-compliant document needs two comments. The first appears on the first line: %!PS-Adobe-3.0 EPSF-3.0. This comment is a flag, indicating to postprocessors that the file is DSC-compliant. Next, every document needs a '%%BoundingBox' comment. This comment tells the postprocessor how big the image is on the page; it describes a rectangle which completely encloses the image. The form of the comment is: %%BoundingBox: llx lly urx ury. For instance, suppose I have an image which extends from x=72 to x=144 and from y=150 to y=170. The first two comments in the document should then be:

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 72 150 144 170
Generally, these should be the first two lines of the file.

There are many other parts to proper DSC. A document which follows the DSC can be manipulated in many ways. In particular, postprocessors can shuffle the pages, print two or more pages on a side, and so on. The printer drivers from some notable companies do not follow the DSC, and their PostScript documents are, therefore, impossible to work with once they've been generated.

Now, What About EPS?

Simply this: any single page document which is DSC-compliant is automatically an EPS document.

In general, if you are creating a PostScript image by hand, all you need to do is calculate the bounding box, add the first comment and the %%BoundingBox comment, and you have an EPS file. Once you have the file in this form, page layout programs can incorporate the image and will allow you to move and resize the image at will.


PostScript Home Page