iink SDK Web

Answered

Exporting Strokes with Protocol REST

Hi there,


I am trying to export and save strokes to be enable users to continue their writing later on after closing the app. I saw a thread on the forum (here) from someone else who has been trying to achieve basically the same feature and it works for me as well as long as I use  

 

protocol: "WEBSOCKET",

 in the recognitionParams when registering the editor. However, as soon as I choose   

protocol: "REST",

 the strokes / exports["application/vnd.myscript.jiix"] are not available anymore. In my use case I cannot guarantee a stable internet connection over a longer period of time which is why i want to use REST and on demand export via button click when the text is complete. My question(s):

  • Are the strokes only available with Websockets? 
  • If so, is there any other way to access the editor's strokes (possibly before sending them to the server)?

Best,
Bryan




Best Answer

Dear Brhempen,


thank you for contacting us and your questions.


In REST, you can also have access to the strokes at export.


For this, you shall ensure you export as JIIX, and export words (set "export.jiix.text.words" to true.


Here is an example of configuration:

{"xDPI": 100,"yDPI": 100,"contentType": "Text","configuration": {"export": {"jiix":{"text":{"words":true,"chars":false}, "strokes":true}},"lang": "en_US"},...


You will then have the corresponding strokes at export. Here is an example:

{
"type": "Text",
"bounding-box": {
"x": 910.859985,
"y": 934.481995,
"width": 251.427979,
"height": 479.012024
},
"label": "§",
"words": [ {
"label": "§",
"candidates": [ "§", "É", "¥", "€", "&" ],
"bounding-box": {
"x": 910.859985,
"y": 934.481995,
"width": 251.427979,
"height": 479.012024
},
"items": [ {
"timestamp": "2022-04-05 15:51:00.068000",
"X": [ 1109.47205, ...],
"Y": [ 1364.23401, ...],
"F": [ 0, ...],
"T": [ 0, ...],
"type": "stroke",
"id": "0000000001008d00ff00"
}, {
"timestamp": "2022-04-05 15:51:00.068000",
"X": [ 1160.27197, ...],
"Y": [ 973.58197, ...],
"F": [ 0, ...],
"T": [ 0, ...],
"type": "stroke",
"id": "0000010001003900ff00"
}, {
"timestamp": "2022-04-05 15:51:00.068000",
"X": [ 1161.28796, ...],
"Y": [ 987.044006, ...],
"F": [ 0, ...],
"T": [ 0, ...],
"type": "stroke",
"id": "000002000100b900ff00"
}, {
"timestamp": "2022-04-05 15:51:00.068000",
"X": [ 1076.95996, ...],
"Y": [ 1144.01599, ...],
"F": [ 0, ...],
"T": [ 0, ...,
"type": "stroke",
"id": "0000030001001901ff00"
} ]
} ],
"version": "3",
"id": "MainBlock"
}


Best regards,


Olivier


Answer

Dear Brhempen,


thank you for contacting us and your questions.


In REST, you can also have access to the strokes at export.


For this, you shall ensure you export as JIIX, and export words (set "export.jiix.text.words" to true.


Here is an example of configuration:

{"xDPI": 100,"yDPI": 100,"contentType": "Text","configuration": {"export": {"jiix":{"text":{"words":true,"chars":false}, "strokes":true}},"lang": "en_US"},...


You will then have the corresponding strokes at export. Here is an example:

{
"type": "Text",
"bounding-box": {
"x": 910.859985,
"y": 934.481995,
"width": 251.427979,
"height": 479.012024
},
"label": "§",
"words": [ {
"label": "§",
"candidates": [ "§", "É", "¥", "€", "&" ],
"bounding-box": {
"x": 910.859985,
"y": 934.481995,
"width": 251.427979,
"height": 479.012024
},
"items": [ {
"timestamp": "2022-04-05 15:51:00.068000",
"X": [ 1109.47205, ...],
"Y": [ 1364.23401, ...],
"F": [ 0, ...],
"T": [ 0, ...],
"type": "stroke",
"id": "0000000001008d00ff00"
}, {
"timestamp": "2022-04-05 15:51:00.068000",
"X": [ 1160.27197, ...],
"Y": [ 973.58197, ...],
"F": [ 0, ...],
"T": [ 0, ...],
"type": "stroke",
"id": "0000010001003900ff00"
}, {
"timestamp": "2022-04-05 15:51:00.068000",
"X": [ 1161.28796, ...],
"Y": [ 987.044006, ...],
"F": [ 0, ...],
"T": [ 0, ...],
"type": "stroke",
"id": "000002000100b900ff00"
}, {
"timestamp": "2022-04-05 15:51:00.068000",
"X": [ 1076.95996, ...],
"Y": [ 1144.01599, ...],
"F": [ 0, ...],
"T": [ 0, ...,
"type": "stroke",
"id": "0000030001001901ff00"
} ]
} ],
"version": "3",
"id": "MainBlock"
}


Best regards,


Olivier


1 person likes this

If the strokes are available with REST - how do I access them?

Thanks, works!