Cannot get AcrofieldPage

Product: SyncFusion.Pdf.Net.Core

Product Version: 26.2.9

Please give a brief summary of your issue:
Annot.GetPage() returns Null

Please describe your issue and provide steps to reproduce it:
Usually we work fine with getting and setting Acrofields on Pdf
I’m attaching a Pdf we are having some issues with

Using this C# Code in a “net8.0-windows” library project
‘’’
public void TestMethod(byte[] pdf)
{
using PDFDoc doc = new(new MemoryStream(pdf));
Field field = doc.GetField(“Text1”);
Annot annot = new Annot(field.GetSDFObj());
Page annotPage = annot.GetPage();
}
‘’’
The variable “annotPage” is null.
“field” and “annot” variables are not null and seem to be correct

Extra Info: If I open the Pdf using “Adobe Acrobat XI Pro”, edit the Acrofield (Like changing the value in the Textbox) and save the Pdf, the issue disappears
If I try the same code snippet on the Pdf, after saving it with Adobe, then it correctly find the page

Please provide a link to a minimal sample where the issue is reproducible:
PdfIssue.pdf (399.7 KB)

1 Like

The issue is that it is Optional for an Annotation to have a reference to its parent Page, and even if present, is not guaranteed to be correct. It really should be ignored, see this forum post.

If you need to know the page a Field Widget Annotation is on, you will have to iterate all the pages, see // Traverse all pages this sample code.

Interactiveformstest | Apryse Documentation?

1 Like