At the moment, we are defining the page number to fetch all of the pdfFormWidgets.
In the document, we have two textboxes (one per page).
When we define the document page and fetch the widget for the first page,
the list comes back with all of the fields.
We are looking to only get one when we define the logic to fetch the first page.
Sample:
- Spire.PDF version 10.6.0 (.NET)
// Iterate through each page of the document
for (int pageNumber = 0; pageNumber < document.Pages.Count; pageNumber++)
{
// Get the page
var page = document.Pages[pageNumber];
// Get the widget from the page
PdfFormWidget widget = page.Document.Form as PdfFormWidget;
// Go through the list of widgets
for (int i = 0; i < widget.FieldsWidget.List.Count; i++)
{
var field = widget.FieldsWidget.List[i] as PdfField;
var fieldObj = new Annotation_Spire
{
Name = ((Spire.Pdf.Widget.PdfStyledFieldWidget)field).Name,
Page = pageNumber,
X = ((Spire.Pdf.Widget.PdfStyledFieldWidget)field).Bounds.X,
Y = ((Spire.Pdf.Widget.PdfStyledFieldWidget)field).Bounds.Y,
Width = ((Spire.Pdf.Widget.PdfStyledFieldWidget)field).Bounds.Width,
Height = ((Spire.Pdf.Widget.PdfStyledFieldWidget)field).Bounds.Height,
};
formFields.Add(fieldObj);
}
}