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:


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" :

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


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 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 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 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


  • 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

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.

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:


>> 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:

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

and then

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

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


(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:


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:


) 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 A. Sergatskov <dasergatskov>
Thu 14 Mar 2019 09:20:37 PM UTC, comment #4:

@Dmitri: There is this comment in _opengl_print_.m

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

... 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:

and then



tpdf2.emf is attached. Looks decent.


(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:

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

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)



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

Attach Files:

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.4