Cannot grab the last edited field when exporting xfdf

Product: Android Native SDK

Product Version: 9.2.3

Please give a brief summary of your issue:
After editing a field in a fillable pdf cannot grab edited info without unfocusing from field.

Please describe your issue and provide steps to reproduce it:
Currently I’m using the ToolManager.AnnotationModificationListener’s onAnnotationsModified function to get the xfdf string of the field after edited. I’m storing an array of fields edited and when save is clicked I send the array to the backend to save.

override fun onAnnotationsModified(
    annots: MutableMap<Annot, Int>?,
    extra: Bundle?
) {
    try {
        annots?.forEach {
            val annot = it.key
            if (annot.type == Annot.e_Widget) {
                val w = Widget(annot)
                val field = w.field
                if (field != null && field.isValid) {
                    val xfdfString = pdfViewCtrlTabHostFragment?.currentPdfViewCtrlFragment?.pdfDoc?.fdfExtract(arrayListOf(annot))?.saveAsXFDF()
                    val name = field.name

                    // Remove previous edit if in there.
                    if (editedFields.containsKey(name)) {
                        editedFields.remove(name)
                    }
                    editedFields[name] = PDFField(
                        id = name,
                        xfdfString = xfdfString
                    )
                }
            }
        }
    } catch (e: PDFNetException) {
                        e.printStackTrace()
    } catch (e: IOException) {
                        e.printStackTrace()
    }
}

I’ve noticed that my code above using onAnnotationsModified callback is only called when the edited field is unfocused. Because of this when hitting the “save” button, the last edited field is not included in the array being sent to the backend. when the user doesn’t first tap outside the field.

How can I grab the updated xfdf value of the edited field if never unfocused before tapping the save button?

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi @seth.pacheco ,

We only modify the document when the field is unfocused. You can switch to the Pan tool to trigger the unfocused event by using the following snippet:

            ToolManager toolManager= mPdfViewCtrlTabHostFragment.getCurrentPdfViewCtrlFragment().getToolManager();
            tm.toolManager(tm.createTool(ToolManager.ToolMode.PAN, null));

You can call this on your save button press to ensure all fields are saved to the document. Could you please give this a try to see if this works for you?

Thanks,
Andrew.

That worked for us. We trigger this on the save icon click or on leaving the page to fetch the latest value. Thank you!

We’re glad the issue’s been resolved. Please feel free to reach out to us if you have any further questions.