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-text-web instance. For example, the following code will import the “Hello iink SDK” text string into a “Text” part:
myscriptTextWeb.import_("Hello iink SDK", "text/plain");
Managed formats are depending on the recognition type of your input.
Text plain import
You can import plain/text data in TEXT
.
Text JIIX import
JIIX import in TEXT
is so far limited to text words candidate changes. More import capabilities will be provided later on.
To change the text candidates within a given Text :
- Export the block to the JIIX format.
- Replace the
label
of the targetword
with another word from thecandidates
list. - Import the modified JIIX data back to your block.
TEXT
is only possible if the target block was not modified since it was exported. For more information, refer to this page.
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-text-web
tag.
Exporting the recognized content as text/plain
myscript-text-web
allows you to get the recognized content in different ways.
You can either use the export_(mimeTypes)
with an array containing all the mime-types
you want to receive as a result.
Or you can choose between application/vnd.myscript.jiix
(Jiix, MyScript JSON format), text/html
or text/plain
.
Once the recognition is done, you receive an exported
event containing the recognized result.
If you ask for text/plain
, text/html
and application/vnd.myscript.jiix
, the next result event will be shaped like this:
{
detail : {
exports : {
"text/plain" : "... Text recognized ...",
"text/html" : "... Text recognized ...",
"application/vnd.myscript.jiix" : "... Text recognized ..."
}
}
}
By default myscript-text-web
exports the content in plain text every time strokes are recognized.
The export
event is fired and contains the recognized content. This behavior can be customized with the mimetypes
attribute.
You can set it with an array that can contain application/vnd.myscript.jiix
, text/html
or text/plain
or several of those 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.
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.