altmany / export_fig

A MATLAB toolbox for exporting publication quality figures
BSD 3-Clause "New" or "Revised" License
1.28k stars 368 forks source link

Ghostscript error: undefined in .setopacityalpha #343

Closed Retroker closed 3 years ago

Retroker commented 3 years ago

It might be a Ghostscript's problem, but it could be helpful if posted here. I am aware of #285 issue, but I was able to come up with a code that may reproduce my issue.

This works perfectly:

f = figure;
bar(1:10)
export_fig(f, 'test.pdf', '-dpdf')

But this gives an error:

f = figure;
bar(1:10, 'EdgeColor','none')
export_fig(f, 'test.pdf', '-dpdf')
Ghostscript error: undefined in .setopacityalpha
 * perhaps C:\Users\XXXXX\AppData\Local\Temp\tp034aeefb_b1b9_477d_bffc_08bd7206b22e.pdf is open by another application
 * or maybe your Ghostscript version does not accept the extra "-dpdf" option(s) that you requested
 * or maybe you have another gs executable in your system's path

Ghostscript path: C:\Program Files\ghostscript\gs9.54.0\bin\gswin64c.exe
Ghostscript options: -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile="C:\Users\XXXXX\AppData\Local\Temp\tp034aeefb_b1b9_477d_bffc_08bd7206b22e.pdf" -dEPSCrop -sFONTPATH="C:\Windows\Fonts" -dpdf -f "C:\Users\XXXXX\AppData\Local\Temp\tpb265779a_9b1c_4aaf_88a5_560761bd9eb1.eps"

Export_fig transparancy is not supported by your Ghostscript version (9.54.0). 
Install GS version 9.28 or earlier to use transparency (details).
Error using eps2pdf (line 258)
Error: /undefined in .setopacityalpha
Operand stack:
   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1
   %stopped_push   1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1988   1   3   %oparray_pop   --nostringval--   1977   1   3   %oparray_pop   1833   1   3
   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:736/1123(ro)(G)--   --dict:0/20(G)--   --dict:120/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 11184
GPL Ghostscript 9.54.0: Unrecoverable error, exit code 1

Error in export_fig (line 914)
                eps2pdf(tmp_nam, pdf_nam_tmp, 1, options.append, options.colourspace==2, options.quality, options.gs_options);

Error in Untitled (line 3)
export_fig(f, 'test.pdf', '-dpdf')
altmany commented 3 years ago

This is a duplicate of issue #285. The underlying cause is due to changes in the Ghostscript engine. A few workarounds were implemented in recent export_fig releases, please ensure that you are using the latest version. See issue #285 for details about this problem, and please follow-up there.

Retroker commented 3 years ago

Sorry to bother you then, I will follow-up there. Yes, I am using the last version of export_fig (downloaded at the same day I've posted the issue).