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?

  • $\begingroup$ It works fine for me, it exports a pdf with the plot to desired location. Mathematica linux 64-bit $\endgroup$
    – ssch
    Nov 6, 2012 at 15:05
  • $\begingroup$ @ssch: Fails every time for me: OS X 10.8.2, Mathematica $\endgroup$
    – orome
    Nov 6, 2012 at 15:13
  • $\begingroup$ Works properly on Windows, too. This problem is apparently specific to OS X. $\endgroup$ Nov 6, 2012 at 18:27

2 Answers 2


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.


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.


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.