No BSD License  

4.9 | 20 ratings Rate this file 163 Downloads (last 30 days) File Size: 2.14 KB File ID: #16179




30 Aug 2007 (Updated )

Saves a figure as a PDF as it appears on the screen.

| Watch this File

File Information

SAVE2PDF saves a figure as a PDF as it appears on the screen. SAVE2PDF is stand-alone and simple--it does not require a separate installation of ghostscript. It saves figures as they appear on the screen, with the correct page size. It has the option to change the resolution to be print-quality.

SAVE2PDF is particularly useful for LaTex users who want to generate PDFs to include when compiling with pdftex. The vector art information is preserved.

This function simply augments the built in print-to-pdf functionality of Matlab by resizing the output PDF and shifting the displayed plot.


This file inspired Saveas2.M V1.1 (Sep 2009), Modeling And Design Analysis Of A Permanent Magnet Linear Synchronous Generator, and Save Figures Shortcut.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Has been tested on Windows (XP) and Linux (Fedora Core 7).
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (21)
09 Jan 2015 David

David (view profile)

This is amazing! I've been waiting my whole Matlab life for this. Saving to a pdf in Matlab is normally rife with difficulties, and this makes the process very simple.

26 Aug 2014 victor

victor (view profile)

23 Jul 2014 Giacomo Ciani

Very handy function, thanks. Just a suggestion: force the 'paperOrientation' property to 'landscape' (that is usually the default); if it has been changed to 'landscape', the function will not produce the expected output.

27 Jun 2014 Chen Chen

really nice function, saves a lot of trouble, thanks

13 Mar 2014 Stephan Koehler  
22 Aug 2013 Tashfeen

Excellent! One of the best utility I found on this forum.

14 Aug 2013 Dan

Dan (view profile)

Really helps when exporting a figure with transparency to PDF.

05 Nov 2012 Sören Sieberling  
27 Jun 2012 UEIH NEYUGN

Great, I was able to adapt to other extension, i.e. pdf, eps ...

24 Jan 2012 Felix

Felix (view profile)

Thank you very much, searched in so many forums to solve exactly this problem!

20 Oct 2011 Kermit

Kermit (view profile)

Very good !

24 Jan 2011 Ariel Balter


02 Jul 2010 Mark

Mark (view profile)

Great Job. Works a charm -- has probably saved me several hours of frustration.

26 Apr 2010 Arnaud

Arnaud (view profile)

Easy to use and 100% useful for Latex users.

02 Mar 2010 Koos Spee

I have got one question regarding dimensions of the saved file.

When I set figure position / size with:
set(gcf, 'Position', [400 400 600 100])
and then apply:

The dimensions of the image will be 450x75

Same with other values of width & height... al get resized to 75%

Does anybody know why this happens?

Comment only
09 Oct 2009 Neil Dalchau

Great function, provided perfect solution first time around!
Many thanks

20 Oct 2008 Richard Stephens

Excellent. Just what I was looking for.

30 Aug 2008 A S

Works good and helps a lot with mass-pdf-graph-generation ... pdf2ps in linux doesn't generate vectorized .ps from these pdfs, but that's not Gabe's fault.

15 Feb 2008 Tim Woolmer

Great stuff - just what I needed. Thanks!

14 Feb 2008 Nathan Miller

Works great and I don't have to manually crop the pdfs.

The only problem I have is that the legend output is different whether you use the command line 'print' or select "save as" from the figure menu. Using 'print', the legend background color is lost and the black outline shows up even when set to white. However, this is a matlab bug, not this code's problem.

05 Sep 2007 Dan Kominsky

Nice and does what it says. But what I'm really interested in is how to save multiple figures to a multi-page pdf without ghostscript. Any thoughts?

24 Sep 2007

Added "Save As" dialog box, so that file name can be omitted in the function call, and ability to change the resolution of the output. Default resolution would be 150 dpi, but typical print-quality should be around 600 dpi.

Contact us