To explain this, a little bit of background may be useful.
I will refer to public available Pdf-Reference from Adobe, found here:
http://www.adobe.com/devnet/pdf/pdf_reference.html(The last link on the Page is the main Reference, the others explain Adobe's extensions)
First of all, an Field in a PDF (a PdfAcroField in terms of PdfSharp) is not a visual entity.
It is merely a container to store and organize data of some sort. (see Chapter 12.7 in the reference)
The visual appearance of a Field is controlled by a WidgetAnnotation.
(Chapter 12.5.6.19, but see also 12.5.2)
Both a WidgetAnnotation and an AcroField are represented by a Dictionary (a PdfDictionary in PdfSharp).
As the reference states (and that's also what i have observed), these Dictionaries may be merged together.
(in fact, from my experience, this seems always to be the case)
So, if you have the Dictionary of an AcroField, you can be quite sure, you also have the Dictionary of it's Annotation.
To get the Position and Size of a PdfAcroField you can use the following:
Code:
PdfRectangle fieldRect = myAcroField.Elements.GetRectangle(PdfAnnotation.Keys.Rect);
(Please note, the position is measured from the lower left of a Page !)
You may also be interested in the Page, where the Field resides (if you're working with multi-page documents):
Code:
PdfReference pageRef = myAcroField.Elements.GetReference("/P");
if (pageRef != null)
PdfPage pageOfField = (PdfPage)pageRef.Value;
As another note, keep in mind, an AcroField may have child-fields, which could contain the information you're after.
So, in the case you do not find a field-rectangle or the Page for a field, make sure to also check the child-fields !
I hope, this will get you started; for more details study the reference, it's really helpful !
Regards,
Thomas