EPS file summary…

Basically, this is a quick summary of key information/knowledge with EPS (encapsulated postscript files). This project is more for myself but if someone else out there finds this useful that’s great as well. I am just trying make sure that I don’t lose any information, so it is being put here so I can reference it later. Hopefully in the new year I will drop EPS files for SVGs (which use in certain cases such as web graphics).


First and foremost this document contains the key details about the most minimal details about creating and using EPS files. A more official document can be found here.

Start EPS files with the following:

%!PS-Adobe-3.0 EPSF-3.0

After the header, specify the bounding box with the following line, which is actually a comment. Note that ‘ll’ the ‘ur’ are the positions of the lower left and upper right corners of the bounding box.

%%BoundingBox: llx lly urx ury  

Limit lengths of lines to 255 characters. Hence, if generating code, be sure to include newlines.

Do not leave anything on the stack. Also do not pop off the contents of what was previously placed onto the stack before the EPS file was used.

Do not assume that the graphics state has been set in any special way. All graphics state changes need to be done within the EPS file.

Showpage should not be called at the end of the file. It can be, however the caller will usually (or should) disable it so it will do nothing anyways.

A preview can be included in an eps file using the %%Begin(End)Preview comments. For quick and practical purposes, it does not need to be included.

There are certain postscript commands that are forbidden in EPS files (such as for processing jobs). Consult the official documentation for complete details.

Using in Latex

It is super easy to use EPS files in latex.

In the preamble make sure that graphicx is being used…


Then in the document the eps file is displayed using includegraphics:


Note that includegraphics can take optional parameters such as width and height.

Using in Postscript Files

Using EPS files in regular postscript files is a little more tricky. First to use the file, one needs to ‘run’ it. For example:

(EPS_FILE.eps) run

Next, one needs to add some extra code so that: is it positioned and scaled, showpage is disabled, and the graphics state is set to its default state:

/showpage {} def
0 setgray 0 setlinecap 1 setlinewidth
0 setlinejoin 10 setmiterlimit [ ] 0 setdash newpath
XPos YPos translate % and/or scale
(EPS_FILE.eps) run

Finally, we must note that including an EPS file in a postscript file is not very safe since it is a script that is being executed and it may contain malicious code. Back in 2017, Microsoft word had disabled support of EPS file because of this issue. Since, I only use EPS files on a limited basis myself (mainly when I created them), then I do not mind occasionally being unsafe.

When converting to PDF, the -dNOSAFER argument needs to be used:



No Comments

Add your comment