How do I get an object if I have its indirect reference?

I am using iTextSharp to analyze a form enabled PDF. I know how to navigate to the radio button control. I would like to analyze the individual radio buttons.

I have the PdfArray of the "kids" for the radio button. Each item in that array is a PdfIndirectReference. How do I get the actual object when all I have is the PdfIndirectReference?

Posted on StackOverflow on Jul 12, 2013 by epotter

Suppose that array is the PdfArray object, then you have a complete series of methods to get its elements. You're probably using the Get() method, but you should use the GetDirectObject() one of the GetAsX() methods. For instance:

PdfDictinary d = array.GetAsDict(0);
PdfArray a = array.GetAsArray(1);
PdfObject o = array.GetDirectObject(2);

Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now