# Import and export

This page drives you through available possibilities to import content into iink SDK or to export it for external usage.

## Importing content

You can import data into your myscript-math-web instance. For example, the following code will import the “Hello iink SDK” text string into a “Text” part:

myscriptMathWeb.import_("Hello iink SDK", "text/plain");

Managed formats are depending on the recognition type of your input.

Importing content is “destructive”: Pre-existing content will be cleared and replaced.

### Math import

Currently, MATH supports only JIIX import.

### Raw ink import

To import raw ink pointer events, instantiate an editor and pass it an array of pointer events. Note that in this scenario, except if you are working on a “Drawing” part, the recognition engine will automatically process the new strokes. This approach is documented in the Editing part of this guide.

## Exporting content

By default, an exported event is fired every time some content is recognized on the server side. The event is shaped like in the example below.

{
detail : {
rawResult : {
type:"exported",
partId:"xdyygiil",
exports:{"text/plain":"mycontent"}
}
}
...
}

If you want to override the default behavior and if you are willing to export “on demand” (by calling the export_() method), you have to set

the ondemand attribute to your myscript-math-web tag.

## Exporting the recognized content as LaTeX, MATHML, Office OpenXML or JIIX

myscript-math-web allows you to get the recognized content in different ways. You can either use the askForExport(mimeTypes) with an array containing all the mime-types you want to receive as a result. Or you can choose between application/x-latex (LaTeX), application/mathml+xml (MathML), application/vnd.myscript.jiix (JSON internal format) or application/mathofficeXML (Office Math XML fragment format). Once the recognition is done, you receive an exported event containing the recognized result. If you ask for both LaTeX and MATHML, the next result event will be shaped like this:

{
detail : {
exports : {
"application/x-latex" : "... LaTeX recognized ...",
"application/mathml+xml" : "... MATHML recognized .. "
}
}
}

By default myscript-math-web exports the content in LaTeX every time strokes are recognized. The export event is fired and contains the recognized content as LaTeX. This behavior can be customized with the mimetypes attribute. You can set it with an array that could contain application/x-latex (LaTeX) or application/mathml+xml (MATHML) or even both values. If you set the array to an empty value, automatic export will be deactivated.

## Supported imports/exports

### Exchange format

Interactive Ink SDK defines its own format, called JIIX (short for JSON Interactive Ink eXchange format).

This format provides a consistent representation of the different types of content that are supported, covering semantics, positions, styling and ink-related aspects.

Thanks to its JSON syntax, it stays readable and can be easily parsed, making it appropriate to exchange information with the host application or as a transitory representation to support custom export formats.

The complete JIIX reference can be found here.

### Other formats

Interactive Ink SDK allows you to import and export some commonly used formats, such as LaTeX for math content or Docx in the case of Text Document blocks.

The full list can be found here.