7

Here's the code to reproduce an error.

First I generate a bar chart:

expr = BarChart[{1, 1, 2}]
pic = First@ImportString[ExportString[expr, "PDF"]]
filename = "img.emf"

(the "pic" operation is necessary to preserve formatting when exporting to EMF - I've found this solution here on MMa.SE)

Than I try to export it:

Export[filename <> ".emf", pic, ImageResolution -> 4100]

Large ImageResolution is a trick to make Mathematica export a vector EMF - another trick I picked up on MMa.SE.

The Export crashes Mathematica kernel. This bug seems to be BarChart specific, as I cannot reproduce is if a swap BarChart for ListPlot.

I use the newest - 11th version. Any suggestion on how to fix it will be much appreciated.

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
  • 1
    Can't reproduce because Linux, but svg works fine Export["img.svg", pic, ImageResolution -> 4100], svg is closely analogous to emf. – Feyre Aug 30 '16 at 17:42
  • @Feyre, I'm on Win7 x64. My purpose is to use it as image in Word and svg is not supported. Additionally I have no problems with this routine in mma 10. – Ekaterina Urakova Aug 31 '16 at 07:28
  • 1
    Then I don't think there's much you can do except register this with support as a bug, considering the upvotes one would assume three people reproduced the issue. – Feyre Aug 31 '16 at 09:42
  • I'm on Win7 x64 but I don't get the crash with version 11.0.0 and the exported EMF file contains rasterized version of the figure. – Alexey Popkov Sep 02 '16 at 08:35
  • 2
    It appears the trick to make Mathematica export an vector EMF no longer works in Mma 11. On Win 10 Mma 11 produced a 749 MB EMF and caused all kinds of hang problems requiring a hard reboot. A small EMF (without the ImageResolution specified) was produced without a problem (except for not being a vector graphic). – Chris Degnen Sep 02 '16 at 09:23
  • 1
    Unfortunately I think your workaround will have to be to export as a PDF from 11, import the PDF in version 10, and export the EMF from there. At least, until this bug is fixed. – Oleksandr R. Sep 02 '16 at 10:29
  • @AlexeyPopkov, thanks for your suggestion. I need the vector file so can't drop the ImageResolution... – Ekaterina Urakova Sep 02 '16 at 14:17
  • @ChrisDegnen, thanks for reproducing this glitch! Hopefully this helps attract more attention to this bug. – Ekaterina Urakova Sep 02 '16 at 14:19
  • @OleksandrR., thanks for your suggestion! However I need the ability to export EMFs routinely and there're no major features in the new version that I would need... So I'm probably skipping this update until more stable version is available.. – Ekaterina Urakova Sep 02 '16 at 14:20
  • @EkaterinaUrakova I didn't dropped ImageResolution -> 4100 during my test. I strongly suspect that the result depends on the graphical card (mine is an old ATI Mobility Radeon HD 3400 Series). – Alexey Popkov Sep 02 '16 at 14:29
  • 1
    I have successfully used ".eps" as a vector graphics format for export to MS Word. Inside Word they looked dreadful, but on export of the final document to PDF, you wouldn't know that MS had been anyway near them. – mikado Sep 03 '16 at 13:49
  • @mikado, thanks! will definitely try: I've tried to paste them into Word and they definitely looked substandard.. Now will try to export to pdf. – iav Sep 07 '16 at 07:09
  • Not solved in 11.0.1. – iav Oct 03 '16 at 10:44

1 Answers1

1

I can't reproduce the crash with versions 10.4.1, 11.0.1 and 11.1.0 on Windows 7 x64: both with ImageResolution and without it I get the same EMF file with rasterized plot in it. The common way to avoid rasterization is to remove the Opacity directives:

plot = BarChart[{1, 1, 2}, PerformanceGoal -> "Speed"] /. _Opacity -> (## &[]);
Export[filename <> ".emf", plot]

Now plot is correctly exported as EMF in the all mentioned versions without rasterization.

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368