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.
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?
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.
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()
}?
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/