Is there any way with iTextSharp to retrieve the action contained in a button field contained in a pdf?
I want to know what action that button field will do when clicked on (on MouseUp).
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Button information is stored as Annotations within the PDF. I wrote some code recently here that enumerated hyperlinks within a PDF (also annotations) and I’ll re-purpose it here for you.
The action of a button can be a bunch of different things, from JavaScript to menu items to playing a movie and more. The code below handles JavaScript, Named Actions and Destination Actions, I’ll leave the others up to you. Named Actions are application-specific and I don’t know if Adobe has a list of what they all are. See my post above for how to resolved a Destination Action (InDirect Reference).
I should note that this pulls the “default action” for a button but its possible to have multiple actions on a button for the various states. To get those, instead of looking at
PdfName.Ayou need to look atPdfName.AAwhich will give you anInDirectReferencethat you’ll need to resolve.