bugGNU Octave - Bugs: bug #55906, emf format no longer works for...

 
 

bug #55906: emf format no longer works for printing

Submitted by:  None
Submitted on:  Wed 13 Mar 2019 08:40:13 AM UTC  
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Octavian Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  5.1.0
Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Mon 18 Mar 2019 12:19:49 PM UTC, comment #21: 

@Rik: Thanks, I pushed the changes:

http://hg.savannah.gnu.org/hgweb/octave/rev/aa9745a1114a
http://hg.savannah.gnu.org/hgweb/octave/rev/1771bed38482

I'll close this report as fixed since the actual regression has been fixed. I could verify today at work that, on Windows, images were not exported to EMF files in previous versions of Octave either.
This is probably a limitation of the fig device as suggested by Dmitri.

Pantxo Diribarne <pantxo>
Project Member
Mon 18 Mar 2019 03:34:07 AM UTC, comment #20: 

@Pantxo: Directions for merging stable to default.

1) cd dev_branch_directory
2) hg pull
3) hg update
## At this point you are up to date and sitting at the tip of dev.
## Also, the Mercurial history contains both the latest dev and
## stable branch changesets.
4) hg merge stable
5) hg ci -m "maint: merge stable to default"
6) hg push

Rik <rik5>
Project Administrator
Sun 17 Mar 2019 03:57:00 PM UTC, comment #19: 

From "man pstoedit" :

pstoedit  works  by  redefining  some basic painting operators of Post‐
       Script, e.g. stroke or show (bitmaps drawn by the  image  operator  are
       not supported by all output formats.)

If somebody needs bitmap images I guess the only way is to go svg-->inkscape route.

Dmitri.

Dmitri A. Sergatskov <dasergatskov>
Sun 17 Mar 2019 02:45:08 PM UTC, comment #18: 

@Okti: Did images (e.g. colorbars) ever get included correctly in emf files?

@Rik: Yes, I will disentangle those patches, push the (partial?) fix for the regression on stable, and push the format deprecation on default together with an anoucement in NEWS. I just need to know how to do the famous "maint: Merge stable to default." in between.

@Dmitri: Any idea of a magic option that would let images be exported correctly?

Pantxo Diribarne <pantxo>
Project Member
Sat 16 Mar 2019 01:09:07 AM UTC, comment #17: 

This is not perfected yet -- does not work for textures e.g..
(try "demo shading 12 ; print t1.emf"), but seems to work for all
"normal" plots.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sat 16 Mar 2019 12:40:48 AM UTC, comment #16: 

Yep. I skipped rm_print_formats.patch first time around.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sat 16 Mar 2019 12:37:12 AM UTC, comment #15: 

The patches applied for me if I did both of them.  I first applied rm_print_formats.patch and then pdf_emf.patch.  Printing a simple plot to emf then worked, as verified with Inkscape.

It seems like the patches should be split so that printing to emf format is restored on stable in the next bug fix release (5.1.1).  And meanwhile, on the development branch the old print formats can be deprecated and maybe a note put in the NEWS file about that.

Rik <rik5>
Project Administrator
Sat 16 Mar 2019 12:09:35 AM UTC, comment #14: 

The patch would not apply to stable tip for me. So I replaced
print.m and _opengl_print_.m and I am still getting 0 sized emf file.

Dmitri.

Dmitri A. Sergatskov <dasergatskov>
Fri 15 Mar 2019 11:09:36 PM UTC, comment #13: 

I attached two patchs:

  • rm_print_formats.patch removes documentation and thus official support for a the formats I had proposed here

http://octave.1599824.n4.nabble.com/Drop-support-for-some-print-formats-td4690049.html

  • pdf_emf.patch changes the tool chain for fig2dev devices as proposed by Dmitri and fixes.

@Okti: If you wan to test the patch on windows, I also attached print.m and _opengl_print_.m. You'll just need to replace  the ones in your Octave installation (make a backup!) by those.

(file #46550, file #46551, file #46552, file #46553)

Pantxo Diribarne <pantxo>
Project Member
Fri 15 Mar 2019 09:09:58 PM UTC, comment #12: 

See if it works now (attaching the t1.emf file)

(file #46548)

Dmitri A. Sergatskov <dasergatskov>
Fri 15 Mar 2019 09:09:10 PM UTC, comment #11: 

This seems like a reasonable suggestion.  We are already creating a toolchain for conversion to EMF so it wouldn't be difficult to change some of the options in that chain and start with pdf rather than eps.

Rik <rik5>
Project Administrator
Fri 15 Mar 2019 09:07:03 PM UTC, comment #10: 

Dmitri is having trouble posting.  Re-posting his comments here that were delivered over e-mail.

OK. I also got decent results by doing:

a) In octave


t = 0:0.1:2*pi;
plot (t, cos(t), "-r;cos(t);", t, sin(t), "-b;sin(t);");
title("Test EMF")
xlabel ("X label")
ylabel ("Y label")
print t1.pdf -svgconvert

b) then in the shell converting using usual toolchain (except using pdf rather than postscript as a starting point).
"-ssp" seems to be the key option to render fonts correctly.

pstoedit -ssp -f fig t1.pdf t1.fig
fig2dev -L emf t1.fig t1.emf

emf file is attached. This is with our "standard" FreeSans font.
The result not so good w/ e.g. Noto font.

Perhaps we can modify the print command accordingly (switch to pdf with svgconvert option).

Rik <rik5>
Project Administrator
Fri 15 Mar 2019 11:19:01 AM UTC, comment #9: 

@Okti:

>> Im sorry for this, but under Windows svg isn't well supported.


I'm sorry as well but on all other platforms, EMF is not supported at all.
My students often use Windows together with Octave. When they want to make presentations and reports using MSOffice, they use Inkscape to convert SVG to EMF and it works pretty well.
I attached a function file that I use to convert svg to pdf, png, eps using Inkscape. I never tested on Windows but it should be easy to have it work (you'll have to add inkscape's directory, e.g. "C:\Program Files\Inkscape", to your path).
I just extended the function to support EMF and verified that in libreoffice the outpout was good looking.

>> What's the problem about getting it worked like in 4.4?


Understanding why it doesn't work anymore.

Ccing Markus who has much more expertise on Windows.

(file #46546)

Pantxo Diribarne <pantxo>
Project Member
Fri 15 Mar 2019 08:38:26 AM UTC, comment #8: 

Im sorry for this, but under Windows svg isn't well supported.
Using Libre Office with svg delivers ugly results. The only way to get good printable resolution is emf. This is al well supported format for many application, because it is native under Windows. Nothing to do as a programmer.

I'm using octave scripts to generate a lot of files. I don't want to use scripts around scripts. octave does not really give arror messages with scripts.

What's the problem about getting it worked like in 4.4?

Okti <oktopus>
Fri 15 Mar 2019 06:46:41 AM UTC, comment #7: 

The best results (again) can be obtained with inkscape:

+verbose+
octave:1> t = 0:0.1:2*pi;
octave:2> plot (t, cos(t), "-r;cos(t);", t, sin(t), "-b;sin(t);");
octave:3> print t1.svg
-verbose-

and then

+verbose+
inkscape t1.svg --export-emf=t1.emf
-verbose-

File attached.
So may be we just document this route for people who really want
emf file?

Dmitri.
--

(file #46543)

Dmitri A. Sergatskov <dasergatskov>
Thu 14 Mar 2019 09:57:20 PM UTC, comment #6: 

Actually some people are relying on this poor emf support:

http://octave.1599824.n4.nabble.com/Drop-support-for-some-print-formats-td4690049.html

But, yes I also think that we should concentrate on improving a few important formats (even MSOffice now supports importing SVG files) rather than trying to maintain dozens of poorly tested ones.

Pantxo Diribarne <pantxo>
Project Member
Thu 14 Mar 2019 09:41:46 PM UTC, comment #5: 

Allegedly, one can get pstoedit to include the font rather than rasterize it (or actually draw with polygons:

http://www.calvina.de/pstoedit/pstoedit#section_12

) but I was not able to do that.

I do not think we could make a good looking emf file on linux.
I am not sure what is better  -- bad looking emf or no emf support at all.

Dmitri.

Dmitri A. Sergatskov <dasergatskov>
Thu 14 Mar 2019 09:20:37 PM UTC, comment #4: 

@Dmitri: There is this comment in _opengl_print_.m

...
  if (! isempty (opts.fig2dev_binary))
    ## fig2dev is prefered for conversion to emf
    fig2dev_devices = {"pstex", "mf", "emf"};
  else
...

Is there a reliable way to view an emf file on linux? I tried to import your emf file in LibreOffice but the text looks rasterized. I also tried to go through fig2dev after svg->pdf->fig and the text is not rasterized but closed glyph are filled (all except 1 and 2). See attached. So fig2dev is not much more convincing than pstoedit at producing emf files.

Now the question is what made this conversion chain stop working recently on Windows and probably long ago on linux (I checked both Octave 6.0 and 4.2.2 don't work on the same computer):

  • Ghostscript hasn't changed between mxe-octave 4.4 and 5.1. It's been upgraded recently but after the release.
  • fig2dev has changed in between

changeset:   4863:e5acf1d94d33
user:        John Donoghue
date:        Fri Oct 19 15:37:38 2018 -0400
summary:     transfig: update to v3.2.7a

changeset:   4442:78ae68d33e61
user:        John D
date:        Thu Aug 03 14:05:13 2017 -0400
summary:     transfig: update to 3.2.6.a

... but on my platform I have v3.2.6.a, a version that used to work on Windows with Octave 4.4.

So I am at loss :-).

Pantxo Diribarne <pantxo>
Project Member
Wed 13 Mar 2019 11:40:47 PM UTC, comment #3: 

Why do we need to go through fig2dev? pstoedit supports emf.
I also noticed this:

octave:3> plot(1:10)
octave:4> print teps.eps
octave:5> print tpdf.pdf
octave:6> print -svgconvert tpdf2.pdf

and then


pstoedit teps.eps teps.emf
pstoedit: version 3.73 / DLL interface 108 (built: Jul 24 2018 - release build - g++ 8.1.1 20180712 (Red Hat 8.1.1-5) - 64-bit) : Copyright (C) 1993 - 2018 Wolfgang Glunz
No explicit output format specified - using emf as derived from suffix of output file
Error: /undefined in /findfont
Operand stack:
   --nostringval--   (0)   --nostringval--   0   71.38   31.0183   10   Helvetica
Execution stack:
   %interp_exit   .runexec2   --nostringval--   .findfontop   --nostringval--   2   %stopped_push   --nostringval--   .findfontop   .findfontop   false   1   %stopped_push   2044   1   3   %oparray_pop   2043   1   3   %oparray_pop   2024   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   .findfontop   --nostringval--   2   %stopped_push   --nostringval--   2044   1   3   %oparray_pop   2043   1   3   %oparray_pop   2024   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   .findfontop   --nostringval--   2   %stopped_push   --nostringval--   .findfontop   .findfontop   .findfontop   2066   8   4   %oparray_pop   .findfontop   1975   8   4   %oparray_pop
Dictionary stack:
   --dict:973/1684(ro)(G)--   --dict:0/20(G)--   --dict:312/450(L)--   --dict:42/64(L)--
Current allocation mode is local
Current file position is 5462
GPL Ghostscript 9.26: Unrecoverable error, exit code 1
PostScript/PDF Interpreter finished. Return status 256 executed command : gs -q -dDELAYBIND -dWRITESYSTEMDICT -dNODISPLAY -dNOEPS "/tmp/psinRh9E11"
The interpreter seems to have failed, cannot proceed !

and

pstoedit tpdf.pdf tpdf.emf
pstoedit: version 3.73 / DLL interface 108 (built: Jul 24 2018 - release build - g++ 8.1.1 20180712 (Red Hat 8.1.1-5) - 64-bit) : Copyright (C) 1993 - 2018 Wolfgang Glunz
No explicit output format specified - using emf as derived from suffix of output file
   **** Error reading a content stream. The page may be incomplete.
               Output may be incorrect.
   **** Error: File did not complete the page properly and may be damaged.
               Output may be incorrect.

and

pstoedit tpdf2.pdf tpdf2.emf
pstoedit: version 3.73 / DLL interface 108 (built: Jul 24 2018 - release build - g++ 8.1.1 20180712 (Red Hat 8.1.1-5) - 64-bit) : Copyright (C) 1993 - 2018 Wolfgang Glunz
No explicit output format specified - using emf as derived from suffix of output file

tpdf2.emf is attached. Looks decent.

Dmitri.
--

(file #46531)

Dmitri A. Sergatskov <dasergatskov>
Wed 13 Mar 2019 10:43:49 PM UTC, comment #2: 

@Rik: I think producing emf files should work on linux too. The problem happens in pstoedit but we don't see any error since we redirect stderr. The equivalent command is:

plot (1:10)
print -depsc toto.eps
system "cat toto.eps |/usr/bin/pstoedit -f fig | /usr/bin/fig2dev -L emf > /tmp/toto.emf"

What I see is that pstoedit calls Ghostscript which in turn fails

pstoedit: version 3.70 / DLL interface 108 (built: Aug 29 2017 - release build - g++ 7.2.0 - 64-bit) : Copyright (C) 1993 - 2014 Wolfgang Glunz
Error:  in /undefined/findfont--nostringval--(0)--nostringval--071.8832.018310Helvetica%interp_exit.runexec2--nostringval--.findfontop--nos
Operand stack:

Execution stack:
                                                                      tringval--2%stopped_push--nostringval--.findfontop.findfontopfalse1%stopped_push204413%oparray_pop204313%oparray_pop202413%oparray_pop188413%oparray_pop--nostringval--%errorexec_pop.runexec2--nostringval--.findfontop--nostringval--2%stopped_push--nostringval--204413%oparray_pop204313%oparray_pop202413%oparray_pop188413%oparray_pop--nostringval--%errorexec_pop.runexec2--nostringval-                                                                                                                                -.findfontop--nostringval--2%stopped_push--nostringval--.findfontop.findfontop.findfontop.findfontop197584%oparray_pop9721684020
Dictionary stack:
   --dict:/(ro)(G)--   --dict:/(G)--   --dict:/(L)--   --dict:/(L)--
Current allocation mode is local
3254504264GPL Ghostscript 9.26: Unrecoverable error, exit code 1
PostScript/PDF Interpreter finished. Return status 256 executed command : /usr/bin/gs -q -dDELAYBIND -dWRITESYSTEMDICT -dNODISPLAY -dNOEPS "/tmp/psinpkK39S"
The interpreter seems to have failed, cannot proceed !

Pantxo Diribarne <pantxo>
Project Member
Wed 13 Mar 2019 08:24:33 PM UTC, comment #1: 

Changing Item Group to regression.

Printing to emf format does not work on Linux at all so I can't confirm the observation.

As a side note, Octave does produce a 0-byte file on Linux with no warning that printing failed.  There should at least be a warning/error that printing to EMF is not possible on Linux.

Rik <rik5>
Project Administrator
Wed 13 Mar 2019 08:40:13 AM UTC, original submission:  

The following script works fine in 4.4 and older versions.
In 5.1 the resulting emf file ist empty. The old file is overwritten but the size is 0 bytes.

t = 0:0.1:2*pi;
plot (t, cos(t), "-r;cos(t);", t, sin(t), "-b;sin(t);");
print -demf ./OutPlot.emf

(tested under Windows 10)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #46550:  rm_print_formats.patch added by pantxo (4KiB - text/x-patch)
file #46551:  print.m added by pantxo (28KiB - text/x-objcsrc)
file #46552:  pdf_emf.patch added by pantxo (4KiB - text/x-patch)
file #46553:  __opengl_print__.m added by pantxo (6KiB - text/x-objcsrc)
file #46548:  t1.emf added by dasergatskov (110KiB - image/emf)
file #46546:  inkprint.m added by pantxo (2KiB - text/x-objcsrc)
file #46543:  t1.emf added by dasergatskov (25KiB - image/emf)
file #46531:  tpdf2.emf added by dasergatskov (11KiB - image/emf)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo
  • -email is unavailable- added by oktopus (Posted a comment)
  • -email is unavailable- added by dasergatskov (Updated the item)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 15 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-18 pantxo StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2019-03-15 pantxo StatusConfirmed => Patch Submitted
    2019-03-15 pantxo Attached File- => Added rm_print_formats.patch, #46550
        Attached File- => Added print.m, #46551
        Attached File- => Added pdf_emf.patch, #46552
        Attached File- => Added __opengl_print__.m, #46553
    2019-03-15 dasergatskov Attached File- => Added t1.emf, #46548
    2019-03-15 pantxo Attached File- => Added inkprint.m, #46546
        Carbon-Copy- => Added mmuetzel
    2019-03-15 dasergatskov Attached File- => Added t1.emf, #46543
    2019-03-13 dasergatskov Attached File- => Added tpdf2.emf, #46531
    2019-03-13 pantxo StatusNone => Confirmed
    2019-03-13 rik5 Item GroupIncorrect Result => Regression
        Summaryemf Plot does not work => emf format no longer works for printing

    Back to the top


    Powered by Savane 3.5