2015b ghostscript not found - ps2pdf multi-page ps to pdf

the release notes for 2015b state that "MATLAB no longer ships with theGhostscript® library. Remove all instances of code that use ghostscript.m"
This breaks the our code which prints multi-page ps and then uses ps2pdf to convert to a multipage pdf. So far this is the only way we have found to get the SVG or vector graphics format into a multi-page pdf.
Unfortunately it is now broken, so what do you suggest we replace this with? Is there a way to do this with saveas now? Or can we somehow run the 2014b mex inside 2015b?

1 件のコメント

Jesper Sallander
Jesper Sallander 2015 年 11 月 4 日
We have the exact same problem! Best solution would be if Mathworks could enable the -append functionality for pdf's too in the next release. The only reason for us to go via .ps files is this multi page option which is only available for ps. It is very handy to produce a single pdf report with all the graphs in the same file.

サインインしてコメントする。

 採用された回答

Mike Garrity
Mike Garrity 2015 年 11 月 4 日

1 投票

We stopped shipping Ghostscript with MATLAB because nothing in MATLAB uses it any longer. If you're still using it, you can download it from Artifex and install it. Then you should be able to continue to use it the same way you have been.
I wouldn't think that trying to run the 14b MEX file in a newer version is a good idea, but the MEX file isn't really adding anything here. PS2PDF is a standalone program that comes with the Ghostscript distribution. It's not part of the MEX file that earlier versions of MATLAB used to run the various Ghostscript programs.

6 件のコメント

peter vincent
peter vincent 2015 年 11 月 4 日
We would prefer some solution that did not require the installation of 3rd party apps. We are basically just trying to get multi-page pdfs with vector graphics.
It makes a big difference to the image quality to use vector graphics, and obviously having multi-page pdfs is useful, but the matlab print function does not support -append for pdf. It only allows you to do that for .ps files, which then need to be converted to pdf. So you see our conundrum.
Is there any other way within matlab 2015b to generate a multi-page pdf with vector graphics? It must be a pretty common requirement .....
dr.bagels
dr.bagels 2015 年 12 月 4 日
I completely agree. Matlab's base code might have stopped using ghostscript, but user built toolboxes still do. Ours does, and now our users have to jump through hoops to get everything up and running again. And it's not trivial. Relying on the ghostscript MEX allowed us to have our toolbox be multi-platform. Now we need to have installation instructions for every platform and have users manually dig around to find the exact path to ghostscript and then add it to our toolbox in order for everything to work again. I appreciate that stock Matlab doesn't require ghostscript but please consider that your users (and their users) still might.
Logan Motloch
Logan Motloch 2016 年 2 月 26 日
I also request that Matlab integrate a high quality, saveas or print function that saves a matlab figure EXACTLY as it is displayed in a window. I currently use hgexport to save my plots as a .png file and then combine all files using a 3rd party product in windows. The final product is great, but the process is slow and tedious. I have also tried using 3rd party Matlab submissions (.m files), but these all use Ghostscript, which has proven to be buggy, locks up, and usually does not work when compiled code is run an another users PC.
Long story short, Matlab is an academic tool used to crunch numbers and visualize lots of data. The purpose of the tool is almost defeated if the rendered data is not easily savable.
Walter Roberson
Walter Roberson 2017 年 11 月 13 日
Julie Fourmy comments to Mike Garrity:
Nice to tell. Explaining how to and where to install it on a Mac would be useful. As it is, I have not succeeded to do it for 2 hours. Thanks
Walter Roberson
Walter Roberson 2017 年 11 月 13 日
Julie Fourmy:
For Mac, you can find a Ghostscript install package at http://pages.uoregon.edu/koch/
After installing it, the easiest way to make it available to MATLAB is to make a symbolic link:
sudo ln -s /usr/local/bin/gs /usr/bin/gs
sudo ln -s /usr/local/bin/gs /usr/bin/ghostscript
This is the easier way, not really the best way. The better way is to edit a plist to set the PATH environment variable and tell launchctl to use it; see https://apple.stackexchange.com/questions/106355/setting-the-system-wide-path-environment-variable-in-mavericks
An intermediate way is to instead modify your MATLAB startup.m to contain
setenv('PATH', [getenv('PATH') ':/usr/local/bin'])
However I do not know at the moment whether the program will be looked for as gs (the name the above package installs it as) or as ghostscript
Jan
Jan 2017 年 11 月 13 日
[EDITED] Julie Fourmy posted as flag:
Nice to tell. Explaining how to and where to install it on a Mac would be useful. As it is, I have not succeeded to do it for 2 hours. Thanks
@Julie: Please use flags only to inform admins and editors about contributions which might violate the terms of use, e.g. by rudeness. Thanks.

サインインしてコメントする。

その他の回答 (7 件)

LR
LR 2016 年 6 月 23 日

1 投票

Hi all,
I had the same problem for a while, but then I found the export_fig toolbox, which includes a function called append_pdfs which works well. Here's a link to that: http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig
You may have to download gs9.19 from http://ghostscript.com/download/ though, but that's not a big deal.
ps2pdf isn't working for me,
(I get this error message: Problem converting PostScript. System returned error: 1.'""' is not recognized as an internal or external command, operable program or batch file.)
so I'm going to go with this.
Hope this helps,
L

4 件のコメント

Yang Liu
Yang Liu 2019 年 11 月 23 日
Although I have installed the ghostscript, but there is still one problem as shown in the following picture:
2019-11-22_192023.png
Walter Roberson
Walter Roberson 2019 年 11 月 23 日
We need to see more of the error message.
What shows up for
which ghostscript
munire ozlem cevik
munire ozlem cevik 2020 年 1 月 26 日
Hello,
I downloaded Ghostscript 9.50.
I get the same error message above when I call append_pdfs:
Undefined function or variable 'ghostscript'.
Error in append_pdfs (line 32)
[status, errMsg] = ghostscript(['@"' cmdfile '"']);
which ghostscript returns 'ghostscript not found'.
What should I do for MATLAB to access ghostscript?
Walter Roberson
Walter Roberson 2020 年 1 月 26 日
You need to create something like
function [status, errMsg] = ghostscript(cmd)
[status, errMsg] = system(['ghostscript ', cmd]);
end

サインインしてコメントする。

Attilio
Attilio 2016 年 1 月 9 日

0 投票

I share the opinion of Peter Vincent and Dr. Bagels. The existing commands saveas and print do allow only saving a single figure to a pdf file, yet easily, but saving a previously created set of figures to become a unique pdf has now become unexpectedly complicated. Best regards Attilio Brighenti
Lukas Hoffmann
Lukas Hoffmann 2016 年 4 月 4 日

0 投票

I agree, Matlab should have a standalone option to convert PS to multi-page PDF
Herb 2.0
Herb 2.0 2016 年 4 月 8 日

0 投票

I agree too, this functionality should be available in Matlab
Rajesh
Rajesh 2016 年 10 月 19 日

0 投票

I share the opinion of Peter Vincent. Matlab should have the support for ghostscript. If you would remove it, then Matlab should at least provide native functions to do the same (ps to pdf, or appending pdfs etc.)
Jan
Jan 2016 年 10 月 19 日

0 投票

I do not see the problem: While earlier versions of Matlab contained a specific GhostScript version, the new versions don't. But GhostScript is available for free. I always used the newest version instead of the one shipped with Matlab, e.g. to convert EPS files to PDF.
Calling GhostScript is much easier and works fluently. In opposite to this, there is a bunch of troubles you can get with installing a compatible C-compiler, as the large number of questions demonstrates.
Teizeen Mohamedali
Teizeen Mohamedali 2016 年 11 月 10 日

0 投票

Where do you install Ghostscript - in C:/Program Files, or do you have to move some of the Ghostscript files (which ones? just the .exe?) into the MATLAB root directory in the 'sys' folder?

2 件のコメント

John Isler
John Isler 2017 年 9 月 9 日
I installed the newest version of ghost script, but still had trouble with running ps2pdf. I placed the ghostscript files in several places for Matlab 2016b with not luck. I even matched some gsData definitions to match what earlier versions of Matlab were defining with the script.
John Isler
John Isler 2017 年 9 月 9 日
However, I found export_fig (https://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig) with the '-append' feature to do the trick. Hope this helps!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by