XFDF is not loading

Product: PDFtron Demo

Please give a brief summary of your issue:
We are trying to load xfdf data on pdf , but with PDF1 we not able to load xfdf data.

→ For PDF1 PDF1.pdf (164.1 KB) we are not able to load xfdf data
but on PDF2 PDF2.pdf (1.8 MB) we are able to load xfdf data on it.

Can you help us to identify why XFDF is not loading on PDF1 ?

we are using document?.fdfMerge(fdfDoc) function to load xfdf.

Here is xfdf File :
XFDF_Data.xml (5.0 KB)

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 there,

It appears that your first document, PDF1, does not contain any form fields, only the widget-annotations on the page. The second document, PDF2, does have form fields.

How was the first document, PDF1, created? It is possible that in the creation or editing process that the form fields were not preserved.

Hi,

PDF1 is working on our previous viewer with the Same XFDF.
One thing that we observed is that, If add information PDFInfo in XFDF, it’s able to render the form fields properly.

Just an update if use this code, we are able to load the XFDF in PDF 1

    do {
            try pdfViewCtrl.docLock(true) { _ in
                if let documentxfdf = self.documentController.document?.fdfExtract(e_ptboth) {
                    pdfViewCtrl.getDoc()?.fdfUpdate(documentxfdf)
                    pdfViewCtrl.update()
                }
                let fdfDoc = PTFDFDoc.create(fromXFDF: xfdfString)
                pdfViewCtrl.getDoc()?.fdfMerge(fdfDoc)
                pdfViewCtrl.update()
            }
        } catch let error {
            print("error \(error.localizedDescription)")
        }

Let us know if we are missing something here or any other approach is possible to load XFDF?

Why there is a need to Update empty PdfInfo, which should be already available in PDF?

Could you try using the following code to apply the XFDF to the document?

do {
    let annotationManager = documentController.toolManager.annotationManager
    try annotationManager.updateAnnotations(withXFDFString: "...")
} catch let error {
    print(error)
}

The behavior of the PTPDFDoc.fdfUpdate() and PTPDFDoc.fdfMerge() methods is different especially with regards to form fields and widgets. The suggested API on the PTAnnotationManager class handles all of this for you.

Hi @dluco ,

we wanted to load forms annotations, with this annotationManager we are only able to load annotations.
Form is still not loading with this function. Is their any other approach to load forms and annotations both with out calling this?

if let documentxfdf = self.documentController.document?.fdfExtract(e_ptboth) {
          pdfViewCtrl.getDoc()?.fdfUpdate(documentxfdf)
           pdfViewCtrl.update()
 }?

Thanks.

The PTAnnotationManager method that I mentioned does work for annotations and forms, despite the name of the method.

To help us get on the same page, could you provide a complete sample project or code that we are able to run on our end? This would help us diagnose any issues much more quickly.

If you are not comfortable sharing your code publicly here, please use our dedicated Technical Support Request form here: https://www.pdftron.com/form/request/