3
$\begingroup$

ExportPacket is the most fundamental way we can turn Box forms into string data in other formats via the FE.

For example, a classic way this works is:

First@FrontEndExecute@
  ExportPacket[Cell@BoxData@ToBoxes@Hyperlink["asdasd", "asdasd"], 
   "PlainText"]

"asdasd"

Or

First@FrontEndExecute@
  ExportPacket[Cell@BoxData@ToBoxes@Hyperlink["asdasd", "asdasd"], 
   "InputText"]

"Hyperlink[\"asdasd\", {\"asdasd\", None}]"

It's enormously useful, but obviously entirely undocumented.

Now I'm interested in figuring out what other options it can take. Currently I've scraped up the following formats:

{
 "PostScript", "InputForm", "GIF",
 "BoundingBox", "NotebookString",
 "EnhancedMetafile", "Metafile", "MGF", 
 "CDFNotebookString", "PDF",
 "PICT", "BitmapPacket", 
 "InputText", "PlainText", "DefaultText" (* thanks to John Fultz for this one *)
 } 

But it can take more per John Fultz

So what's the complete list of formats? As a real long shot, what're the other options it can take?


Scraping notes

For those interested, I just scraped those formats from the DownValues of various Export functions:

System`ConvertersDump`installSource[
  DeleteMissing@
   Flatten@Lookup[Quiet[getFormatExportData /@ $ExportFormats], 
     "Sources"],
  Automatic
  ];
epfuncs =
  Quiet@
   ToExpression[DeleteDuplicates@Join[Names["*`*"], Names["*`*`*"]], 
    StandardForm, 
    Function[Null,
     If[FreeQ[DownValues[#], ExportPacket | FrontEnd`ExportPacket],
      Nothing,
      #
      ],
     HoldAllComplete
     ]
    ];
epdats =
  AssociationMap[
   Cases[
     DownValues@#,
     p : (ExportPacket | FrontEnd`ExportPacket)[_, type_, opts___] :>
      {
       "Type" -> type,
       "Opts" -> {opts}
       },
     \[Infinity],
     Heads -> True
     ] &,
   epfuncs
   ];
Cases[Flatten@Values@epdats, ("Type" -> t_) :> t] // DeleteDuplicates
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.