# How can I determine how an Import/Export format works?

Questions abound on the MSE about how to get a certain import / export feature to work as desired. For instance, here's one that popped up recently: How can I standardize the coordinate origin for exported/imported outlines?

Generally this requires digging into the actual source data. So how can I do that? Even if I look in the Names (e.g. Names["**Export*PDF*", IgnoreCase -> True]) I find that the functions aren't loaded until I use them (which I may not want to do) and it's not entirely clear how to get them to load otherwise.

So how can I look at how these types of import / export formats are actually implemented.

This is really a companion post to this question and I'll make use of the scrapers I set up there.

Looking at the PDF case, we can scrape it's export data like so;

getFormatExportData["PDF"]

{"FormatName" -> "PDF", "DocumentedElements" -> None,
"Function" -> SystemConvertPDFDumpExportPDF,
"HiddenElements" -> None, "Options" -> {"AllowRasterization"},
"Sources" -> "ConvertPDF", "BinaryFormat" -> True,
"File" ->
"/Applications/Mathematica.app/Contents/SystemFiles/Formats/PDF/Export.m"}


And we see this odd "Sources" element which maps to a context that can't be loaded with Get or Needs:

<< ConvertPDF

Get::noopen: Cannot open ConvertPDF.

$Failed  Digging further though into ImportExportRegisterExport we find a curious function called installExport which later calls a function installSource. This is really just a forked Get for the different "Sources" types, which generally just means call Get on the package found on the SystemConvertersDump$PackagePath.

This is the key function for us, as calling:

SystemConvertersDumpinstallSource["ConvertPDF", Automatic];


causes our export function to get loaded:

SystemConvertPDFDumpExportPDF // DownValues // Length

4


And then we can start to dig, which shows us two interesting things:

First, PDF export really just goes through the FE. In essence it calls:

First@FrontEndExecute@
ExportPacket[
SystemConvertersDumpcreateVectorExportPacketExpr[expr, opts],
file,
"ConversionOptions" -> attachments
]


Second, we can figure out what some of those opts can be by looking at SystemConvertPDFDumpgetOptions. For example, we can control the "OpacityRenderingMethod", "RasterizationResolution", and "VertexColorRenderingMethod" directly in the Export` call.

Unfortunately, what these values can be is unclear, as this is pulled directly from the FE, but it gives a sense of how you can spelunk these I/E functions