iink SDK on Device

editor.export_() Returning Null When Exporting Selected Content - Project vs. Demo + Alternative Content Retrieval

Hi,

I'm experiencing an issue where the editor.export_(content, ...) function is returning null in my Android project, even when I'm attempting to export what appears to be a valid selection. The same selection exports correctly in the MyScript demo application.

Here's the relevant code snippet:

  

fun exportContent(mimeType: MimeType, x: Float?, y: Float?, selectedBlockId: String?, outputFile: File) {
    editor?.let { editor ->
        val selection = if (selectedBlockId == null && x != null && y != null) {
            editor.hitSelection(x, y)
        } else {
            null
        }
        val content = when {
            selectedBlockId != null -> editor.getBlockById(selectedBlockId)
            selection != null -> selection
            x != null && y != null -> editor.hitBlock(x, y)
            else -> null
        }
        val imagePainter = ImagePainter(extraBrushConfigs).apply {
            setImageLoader(ImageLoader(editor))
            setTypefaceMap(typefaces)
        }
        editor.waitForIdle()
        outputFile.parentFile?.mkdirs()
        editor.export_(content, outputFile.absolutePath, mimeType, imagePainter)
        Log.d("Vivek","Export: ${editor.export_(selection,mimeType)}")
    }
}

 Observations:

  • hitSelection is returning null in my project.
  • The content variable is being set correctly according to the logs.
  • The imagePainter is created with custom configurations.
  • editor.waitForIdle() is called before exporting.
  • The editor.export_(content, ...) call returns null.
  • The editor.export_(selection, ...) call also returns null.
  • When I perform the same selection and export in the MyScript demo app, the export is successful and returns the expected content.
Code Snippet:

fun exportContent(mimeType: MimeType, x: Float?, y: Float?, selectedBlockId: String?, outputFile: File) {
    editor?.let { editor ->
        val selection = if (selectedBlockId == null && x != null && y != null) {
            editor.hitSelection(x, y)
        } else {
            null
        }
        val content = when {
            selectedBlockId != null -> editor.getBlockById(selectedBlockId)
            selection != null -> selection
            x != null && y != null -> editor.hitBlock(x, y)
            else -> null
        }
        val imagePainter = ImagePainter(extraBrushConfigs).apply {
            setImageLoader(ImageLoader(editor))
            setTypefaceMap(typefaces)
        }
        editor.waitForIdle()
        outputFile.parentFile?.mkdirs()
        editor.export_(content, outputFile.absolutePath, mimeType, imagePainter)
        Log.d("Vivek","Export: ${editor.export_(selection,mimeType)}")
    }
}

Specific Questions:

  • What could be causing editor.export_(content, ...) to return null in my project, while the same selection exports correctly in the demo?
  •  Are there any specific configurations or dependencies that might be causing this issue? 
  • Could the custom imagePainter configurations be affecting the export? 
  • How can I further debug this issue to identify the root cause? 
  • What are the differences between the demo app and a user created application that could cause this issue?
  • Are there any alternative methods or approaches to retrieve the content from the MyScript editor besides using editor.export_()? If so, could you please provide some examples or documentation?
SDK Version: 

com.myscript:iink:3.2.0

 Thanks.

Vivek P

+91 9740884288


Hello,


Thank you for contacting us.


This issue may be due to resources lacking into your project deployment. See https://developer.myscript.com/docs/interactive-ink/4.0/android/fundamentals/error-management/#no-recognition

We recommend you to implement the IEditorListener to track errors if any.


If it is still not enough to fix your problem, please share more information about the object that you are using for your recognition (Editor? OffScreenEditor? Recognizer) as well as the content type that you are using.


Best regards,


Gwenaëlle

Hello Gwenaëlle,

Thank you for your response. The issue is resolved now.

I also wanted to check if there is any API available to read math text from an image. Could you provide more details on that?

Best regards,

Vivek

Login or Signup to post a comment