Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As near as I can tell, Export cannot be configured through arguments or options, to present a standard system file save dialog to the user, so that he can specify a location and name for his file. Instead, it seems to require that these parameters be specified as arguments. One way around this is to use SystemDialogInput

Export[SystemDialogInput["FileSave"], ...]

which works fine in simple cases, but in more complex cases, such as the ones I need it for, this fails silently. In particular, I can't get it to work with Show:

Manipulate[f = Plot[Sin[x], {x, 0, Pi}], 
    "Export", {Export[SystemDialogInput["FileSave"], Show[f], "PDF"]},
    ImageSize -> 100, Alignment -> {Center, Baseline}]}]]

Strangely, this works fine if, instead of using Export, a file is specified as an argument.

Why doesn't Export + SystemDialogInput work with Show?

share|improve this question
It works fine for me, it exports a pdf with the plot to desired location. Mathematica linux 64-bit – ssch Nov 6 '12 at 15:05
@ssch: Fails every time for me: OS X 10.8.2, Mathematica – raxacoricofallapatorius Nov 6 '12 at 15:13
Works properly on Windows, too. This problem is apparently specific to OS X. – Oleksandr R. Nov 6 '12 at 18:27
up vote 7 down vote accepted

If I use the option Method->"Queued" within Button, this works

      Export[SystemDialogInput["FileSave"], Plot[Cos[x], {x, 0, Pi}], 
      "PDF"], Method -> "Queued"]

Otherwise, "Preemptive" will be the default, making it possible that not enough time is allocated for the Button action to complete. See the reference docs on Button.

share|improve this answer

The problem seems to be a bug in Button that occurs (at least) in Mathematica 8.0.4 running on Apple OS X. Here is what I determined. The following expression fails

   Export[SystemDialogInput["FileSave", "untitled.pdf"],
          "******", "PDF"]]

while the following two expression work

Export[SystemDialogInput["FileSave", "untitled.pdf"], 
       Plot[Sin[x], {x, 0, Pi}], "PDF"]

   Export["/Users/oldmg/Desktop/test.pdf", "******", "PDF"]]

So I don't think the problem has anything to do with graphics.


Reworking raxacoricofallapatorius' post with david's answer taken into account, I tried

Manipulate[f = Plot[Sin[x], {x, 0, Pi}], 
  Button["Export", Export[SystemDialogInput["FileSave", "untitled.pdf"],
                          f, "PDF"], 
         ImageSize -> 100, Method -> "Queued"]] 

This worked like a charm. Note there is no need to use Row or Show. Also, adding the second argument, "untitled.pdf", to SystemDialogInput makes for a much improved Save dialog. I do think it would be a good idea to localize f by adding {f, ControlType->None} to the Manipulate.

There is still a bug in Export. If you cancel out the Save dialog, you will get an error message that you shouldn't. This may be OS X specific.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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