View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.8 | 19 ratings Rate this file 36 Downloads (last 30 days) File Size: 4.23 KB File ID: #5782 Version: 1.0



Primoz Cermelj (view profile)


25 Aug 2004 (Updated )

Converts an EPS file to a PDF file.

| Watch this File

File Information

EPS2PDF converts an existing EPS file to a PDF file using Ghostscript. EPS2PDF reads an eps file, modifies the bounding box and creates a pdf file whose size is determined by the bounding box and not by the paper size. This can not be
accomplished by using Ghostscript only. So, all that one needs is of course MATLAB and Ghostscript drivers.

This tool is especially suited for LaTeX (TeX) users who want to create pdf documents on the fly (by including pdf graphics and using either pdftex or pdflatex). An example would be, if you are using LaTeX (TeX) to typeset documents then the usual (simple) way to include graphics is to include eps graphics using for example (if there exists myfigure.eps)

  \caption{some caption.}

To use pdflatex (pdftex) you do not need to change anything but provide another file myfigure.pdf in the same directory along with myfigure.eps. And this file, of course, can be generated by EPS2PDF.


This file inspired Savefig.

MATLAB release MATLAB 6.5.1 (R13SP1)
Other requirements Ghostscript
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (24)
21 Jan 2017 James

I found the solution to my query, a setting had changed on the postscript printer dialogue box. The advanced printer settings tab's postscript options had somehow changed to 'Optimize for speed' instead of 'Encapsulated Postscript (EPS)' so when i sent a diagram to print to file (ps), something was missing.

Comment only
18 Jan 2017 James

I have been using your very useful eps2pdf converter for a number of years. Suddenly it refuses to remove whitespace from my postscript (eps) diagrams. When I convert from .ps to .eps the whitespce is removed but when I convert from eps2pdf the whitespace comes back. Kindly advise on what I should do.
(Unfortunately I cant see how to upload my eps file here)

Comment only
29 Mar 2014 Jeppe Druedahl

This is very good script. On a 64-bit Windows 7 machine I sometimes get the error

"r6016: not enough space for thread data"

The error disappears when I use a 32-bit version of Ghostscript.

22 Apr 2013 David T

This script has worked very well for me through Windows XP and Windows 7. Note, that you do need to locate the exact path to the ghostscript file on your local drive. The example provided in the .m notes is just that, an example and will likely not reflect where the gs file is located on your machine.

For Windows 7, i found that the OS doesn't have a suitable gs to path to. has a free download for ghostscript 9.07 which resolves this problem. Just path to the .exe and change the eps2pdf script to the correct file name and you're all set.

05 Nov 2012 Spase

Spase (view profile)

I just downloaded the code but I’m having a problem using it.
I have a Ghostscript version 9.05 running on 64 bit Windows 7, so I changed the part of the code to be gswin64c.exe instead of gswin32c.exe, and I included the right path as input argument, but it shows me the error “Ghostscript executable could not be found: c:\programfiles\gs\gs9.05\bin\gswin64c.exe”

Does anyone have any idea how could I solve this?

Comment only
23 Aug 2012 Eike

Eike (view profile)

18 Feb 2012 Marmar

Marmar (view profile)

Many thanks for this helpful code. Would you please let me how you give the resource and dest addresses via an example?

Comment only
27 Nov 2011 Maria

Maria (view profile)

This is genial and works on Linux!!! I am glad I have found this page!

Big big thanks!

25 Oct 2011 Uli

Uli (view profile)

Great job. Thanks a lot!

03 Aug 2011 Folkert

Beware that this does not embed fonts in the PDF generated! I used this to create figures for an IEEE paper (which requires all fonts to be embedded) with pdflatex. The only way to get all fonts embedded was to embed them in the figures.

I did this by adding the following options to GS_PARAMETERS:


It might be an idea to include these options by default or to comment on this in the comment for the file.

Apart from that it is a great function, I combine it with the function 'exportfig'.

01 Nov 2010 Ran

Ran (view profile)

This is exactly what I want!

12 Apr 2010 J.Paul Rinehimer

18 Sep 2009 Fabio Caponetti

Works smoothly under Linux!:)

10 Sep 2008 Mark Tschopp

This script works great!

21 May 2008 Zhaowen Wang

it helps a lot!

17 Apr 2008 h h


Comment only
03 Dec 2007 Jan K.

wonderful, thank you very much!

13 May 2007 Ryan Edwards

This function is exactly what's needed to convert EPS files printed from MATLAB into PDF's that can be interpreted correctly by pdflatex. (A rant: I think it's stupid that pdflatex cannot directly place EPS or PS files when standard latex can. I'm sure there's a reason, but I still think it's stupid. Annoying nuances like this will keep people using Word). Anyway, I'm looking forward to putting this function through its paces with some papers I'm writing. Many thanks for this contribution.

20 Mar 2006 dsg dghnd

19 Feb 2006 Sebastian F

Just what I was looking for!!!!!!!!!!
Thanks, thanks, thanks!!!!

08 Feb 2006 evgeni lomonosov


02 Sep 2005 Steve B

Thanks!!!! This is perfect!

21 Jun 2005 Michael Hofer

Very useful, many thanks!

03 Sep 2004 Behzad Samadi

Excellent! Thanks a lot Primoz! After a few hours of searching, I found the perfect answer here.

27 Aug 2004

Optimized for speed

Contact us