ExportPacket ­ A Request for a Graphic

A bitmap can be requested from the front end using ExportPacket.  This is not a kernel function in the traditional sense.  It is just a wrapper that is sent to the front end via a MathLink connection.  The syntax is as follows.

ExportPacket[expression, format]

The packet is sent from the kernel to the front end using LinkWrite, and the result is obtained with LinkRead.

The value of expression can be any valid Cell or Notebook expression.  The format can be any of the following strings: PostScript, Bitmap, MGF, GIF, or PPM.  

The expression returned by the packet request is a three-element list.  The first element is a Mathematica string containing the graphic.  The second element is a 2 × 2 list of reals containing the high-resolution EPS bounding box values as they would appear in the header of the EPS value.  The third element is a real containing the value of the baseline.  Neither the bounding box nor the baseline values are of interest in bitmap conversions.

The packet supports an optional third argument for bitmap formats, which is a string containing a filename.  This instructs the front end to write the bitmap directly to a file on the front end's file system.  The return expression replaces the graphic in the first element with the full filename's path written as a FrontEnd`FileName object.

Care must be exercised in forming the expression that is sent with the packet.  The front end can be unpredictable about what line width it uses to compute breaks, so it is usually wise to specify an explicit value for the PageWidth option.  You may also force the front end to use a different style sheet through the StyleDefinitions option.  

With the exception of PostScript,  the default environment is determined by the setting for ScreenStyleEnvironment.  For PostScript, PrintingStyleEnvironment is used instead.

The following options apply to all target formats.

ShowCellBracket ­ This option overrides any other explicit settings of this option at both the notebook and cell levels.  It can be set to True or False.

Bounds ­ This option specifies what bounding box should be used to draw the graphic.  It can be set to ContentsBoundingBox, CellElementsBoundingBox, CellBoundingBox, or a list of values of the form {{xl,xr},{yt,tb}}