7
$\begingroup$

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.

$\endgroup$
13
  • 1
    $\begingroup$ Can't reproduce because Linux, but svg works fine Export["img.svg", pic, ImageResolution -> 4100], svg is closely analogous to emf. $\endgroup$
    – Feyre
    Aug 30, 2016 at 17:42
  • 1
    $\begingroup$ 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. $\endgroup$
    – Feyre
    Aug 31, 2016 at 9:42
  • 2
    $\begingroup$ 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). $\endgroup$ Sep 2, 2016 at 9:23
  • 1
    $\begingroup$ 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. $\endgroup$ Sep 2, 2016 at 10:29
  • 1
    $\begingroup$ 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. $\endgroup$
    – mikado
    Sep 3, 2016 at 13:49

1 Answer 1

1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.