Featured post
c# - Get the export value of a checkbox using iTextSharp -
i'm working on dynamically filling in fields on pdf document using itextsharp. i'd able determine "export value" of checkbox codebehind in order determine value send checkbox if should checked. of documents i've worked in past had same export value every check box 1 i'm working varies checkbox checkbox. go through of text boxes , make them consistent save lot of time in future if determine export value of these checkboxes @ runtime , set them accordingly.
thanks in advance!
i tried implement solution below in c# , ended following code:
public string getcheckboxexportvalue(acrofields pdfdocument, string checkboxfieldname) { acrofields.item item = pdfdocument.getfielditem(checkboxfieldname); if (item.values.count > 0) { pdfdictionary valuedict = item.getvalue(0); pdfdictionary appearancedict = valuedict.getasdict(pdfname.ap); // if there's appearance dict @ all, 1 key "off", , other // export value... there should two. if (appearancedict != null) { foreach (pdfname curkey in appearancedict.keys) { if (!pdfname.off.equals(curkey)) { return curkey.tostring(); // string have leading '/' character } } } // if doesn't work, there might /as key, value name // export value, again leading '/' pdfname curval = valuedict.getasname(pdfname.as); if (curval != null) { return curval.tostring(); } } //return null if far return null; }
this returns "/d" every single time. i'm not sure if approach needs different in c# or if i'm missing something.
okay, need check low-level pdf objects appropriate values. can said values in pdf reference (chapter 12: interactive features, section 7: interactive forms).
in particular (and in java):
acrofields.item item = acrofields.getfielditem(fldname); pdfdictionary valuedict = item.getvalue(0); pdfdictionary appearancedict = valuedict .getasdict(pdfname.ap); if (appearancedict != null) { pdfdictionary normalappearances = appearancedict.getasdict(pdfname.n); // /d "down" appearances. // if there normal appearances, 1 key "off", , other // export value... there should two. if (normalappearances != null) { set<pdfname> keys = normalappearances .getkeys(); (pdfname curkey : keys) { if (!pdfname.off.equals(curkey)) { return curkey.tostring(); // string have leading '/' character } } } } // if doesn't work, there might /as key, value name // export value, again leading '/' pdfname curval = valuedict.getasname(pdfname.as); if (curval != null) { return curval.tostring(); }
something that. usual "i wrote in edit box here" provisions apply, should go. write distressingly large amount of low level itext code.
- Get link
- X
- Other Apps
Comments
Post a Comment