Code covered by the BSD License  

Highlights from
ps2pdf

4.57143

4.6 | 14 ratings Rate this file 103 Downloads (last 30 days) File Size: 5.37 KB File ID: #19516
image thumbnail

ps2pdf

by

 

09 Apr 2008 (Updated )

Convert PostScript file to PDF using Ghostscript; can generate multi-page PDF files.

| Watch this File

File Information
Description

Converts a postscript file into PDF. The resulting PDF file will contain one page for each page defined in the postscript file, so a multi-page postscript file, like those generated by using the '-append' option of MATLAB's print command, can be used to generate a multi-page PDF file.

Works with the version of Ghostscript shipped with MATLAB, if found, or with a user-specified version.

Also works with older MATLAB versions, such as R2006b.

Acknowledgements

This file inspired Gui2pdf.

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Deployed applications require a separate installation of Ghostscript.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (22)
28 Apr 2012 Andrea Gentilini

Fantastic tool. Would be even better if it allowed user to control for portrait or landscape orientation. I saw other users have requested the same. Thanks, Andrea

09 Nov 2011 suraj

great tool anyday!! need help with minor issue. when I have a figure with rotated xticklabels and I append it to a ps file which I make into a pdf using ps2pdf, the figure gets rotated so that the text is now horizontal. any way to force orientation to landscape while writing to pdf? thanks.

02 Nov 2011 David Berns

When i run this program in a folder where the path has a parentheses in it, e.g. C:\DriveName\User(David)\, this program produces the following error: Problem converting PostScript. System returned error: -13.Unrecoverable error: limitcheck in .putdeviceprops.

I indeed tried the program in a folder whose path doesn't have a parentheses and it seems to work fine.

Thoughts?

04 May 2011 Michael Teo

Oh, i found the solution.

I have to set the MATLAB print to landscape by

orient landscape;

04 May 2011 Michael Teo

Can i print the PDF to A4 landscape?

28 Mar 2011 Robert Cumming  
18 Mar 2011 Rossella

Great function! Really useful.
Is there a way to set the PDF paper to horizontal (either letter or A4)? I tried each possible gspapersize, but I didn't find anyone working fine in this case.

22 Jul 2010 Esben Vedel-Larsen

Very nice file, I have found it very usefull. I had the same problem with the version, but the newest file solved it, Thank you!

22 Jul 2010 Esben Vedel-Larsen  
20 Jul 2010 Felix

Any way to include ps2pdf.m and ghostscript in a compiled application?

22 Apr 2010 Kristo K

Yes, I had the same problem after upgrading to 7.10. I just commented out the if-else starting on line 289, and it will just default to using the internal ghostscript for now.

09 Apr 2010 Can Baran

I think this is pretty well written. One thing to comment:
I just upgraded to 2010a, the line at 287:
if str2double(v.Version) < 7.4
v.version is = 7.10 which is bigger than 7.4 but str2double of 7.10 is smaller than 7.4
So, there might be a better way of dealing with this than the one i am about to write:
compare the first digit(s) before the point, if they are the same, compare the digit(s) after the point. I think this is a still pretty damn solid .m file, I wish i could give 4.5 stars.

04 Feb 2010 Per Bröms

Very nice. This work very good for me.

I found two bugs thou.

1) You need to put " (double quote) around the Ghostscript input file name. If you have space chars in the path e.g. "\\server\directory with space in the name\myinput.ps" it will crash otherwise. So line 123 and 125 need to be modified.

New 123- [s, r] = gsData.cmd(['@' gsData.responseFile], ['"' gsData.psFile '"'], gsDebug);

New 125- [s, r] = system([gsData.cmd ' @' gsData.responseFile ' "' gsData.psFile '"']);

2) To work with really old version of MATLAB, like R14, you need to remove the () after Local_GetOldGhostscript(); in line 288

New 288- [gsCmd, ghostDir] = Local_GetOldGhostscript;

Now it work on R14 and with all directory names.
Also tested on 2006b.

Thanks,
/Per

04 Feb 2010 Per Bröms  
14 Oct 2009 Andrew Bytheway

Great idea! I did experience problems when using this script in a deployed application (R2009a). The built-in version of Ghostscript doesn't work in deployed applications. It returns the following error:
??? Undefined function or method 'gscript' for input arguments of type 'char'.
Clearly it is failing to recognize the call to gscript altough the function handle was created correctly, and the needed mexw32 file is distributed with the MCR v7.10

Any ideas ???

07 Jan 2009 Tom Mat

The Title (push Ctrl+Shift+D in Acrobat) of the pdf files, is the name and path of the ps File. It would be good to have an option to avoid this...

07 Jan 2009 Tom Mat  
10 Sep 2008 Mat K

Great Script, options to set Author, Title, Subject etc. would make it superior...

22 Aug 2008 Pat Murray

Excellent, exactly what I needed, saves me a time-consuming step for my project.

Thanks!

04 Aug 2008 Naveen K

Perfect. Exactly what i needed. Many thanks Richard.

01 Jul 2008 Pablo Pablo

Excelent script.
Tested on Matlab2008a
Thanks a lot.

09 Apr 2008 Yuri Kotliarov

It's amazing! I just started looking for this feature and found this function dated TODAY. Tested on 2007b. Works like a charm. Thanks a lot!

Updates
14 Apr 2008

added screenshot

21 Apr 2008

added option to delete input postscript file after creating pdf file. Default is to NOT delete the input ps file

16 Jun 2010

Added check for deployed applications, plus some bug fixes and minor documentation updates.

Contact us