c# - How to get values from textbox comments in pdf document -
i have pdf document, inside comments lists of 2 types : 1. rectangle 2. text box
i want values text boxes c# , itextsharp.
the text boxes , rectangles you're referring called annotations. annotations defined dictionaries , listed per page.
in other words: need create pdfreader
instance , annots
each page:
pdfreader reader = new pdfreader("your.pdf"); (int = 1; <= reader.numberofpages; i++) { pdfarray array = reader.getpagen(i).getasarray(pdfname.annots); if (array == null) continue; (int j = 0; j < array.size; j++) { pdfdictionary annot = array.getasdict(j); pdfstring text = annot.getasstring(pdfname.contents); ... } }
in above code sample, have pdfdictionary
named annot
, can extract contents. may interested in other entries (for instance name of annotation, if any). please inspect keys available in annot
object in case contents
entry isn't you're looking for.
replace dots whatever want text. pdfstring
has different method reveal contents.
disclaimer: i'm original developer of itext (i assume people know this, once downvoted because didn't add disclaimer).
Comments
Post a Comment