How can I find the number of the page that a specific text field is on?


I have a PDF document, and on one of its pages is a field with the name “FOO”. How can I find the page number of that page?


First you will need to traverse the document’s annotations, as in the following code sample:

Then, you will need to modify the sample to have it check text field names, like so:

if (annot.GetType() == Annot.Type.e_Widget) {
Field field = annot.GetWidgetField();
string fieldName = field.GetName();
// check if fieldName is “FOO”…

If you’re following the Annotation sample, the page_num variable holds the current page number.