Re: 1.11.5 Exporting Formulas from Notebooks
- To: mathgroup at smc.vnet.net
 - Subject: [mg25161] Re: 1.11.5 Exporting Formulas from Notebooks
 - From: "P.J. Hinton" <paulh at wolfram.com>
 - Date: Tue, 12 Sep 2000 02:58:48 -0400 (EDT)
 - Organization: Wolfram Research, Inc.
 - References: <8pfell$d4q@smc.vnet.net>
 - Sender: owner-wri-mathgroup at wolfram.com
 
On 10 Sep 2000, Phlip wrote:
> How do you export a formula if you don't have a graphic front-end or a
> notebook?
> 
> If you have a front end available, you can write:
> 
>     Export["file.GIF", ToBoxes[/formula expr/], "GIF"]
> 
> If you don't, you can still export something that returns a raster
> image:
> 
>     Export["file.GIF", Plot[/graphable expr/], "GIF"]
> 
> If there's no special function (like Display[/formula expression/]) I
> can put in the middle variable to convert a math expression to a nicely
> drawn math formula, 
The kernel has no innate ability to generate the visual result of
rendering a Mathematica box structure.  To get such a bitmap, you must
have a front end present.
> is there someway I can tell MathLink (my conduit to the kernel) to
> grab the nearest graphical front end and have its way with it?
You can launch the front end in MathLink mode as a child process of the
kernel and then set $FrontEnd to point to the corresponding LinkObject[].
frontEndCommand[] :=
  Switch[
    $OperatingSystem,  
    "Windows"|"WindowsNT", 
    ToFileName[{$TopDirectory}, "Mathematica.exe"],
    "Unix", 
    ToFileName[{$TopDirectory, "Executables", $SystemID}, "Mathematica"],
    _,
    $Failed
  ]
$FrontEnd = 
  FrontEndObject[LinkLaunch[frontEndCommand[] <> " -mathlink"]];
Export["testme.gif", ToBoxes[Expand[(x+y)^10]], "GIF"]
-- 
P.J. Hinton
User Interface Programmer                         paulh at wolfram.com
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.