Checking off pdf checkbox with itextsharp -
i've tried many different ways, can't check box checked! here's i've tried:
var reader = new itextsharp.text.pdf.pdfreader(originalformlocation); using (var stamper = new itextsharp.text.pdf.pdfstamper(reader,ms)) { var formfields = stamper.acrofields; formfields.setfield("isno", "1"); formfields.setfield("isno", "true"); formfields.setfield("isno", "on"); }
none of them work. ideas?
you shouldn't "guess" possible values. need use value stored in pdf. try checkboxvalues example find these possible values:
public string getcheckboxvalue(string src, string name) throws ioexception { pdfreader reader = new pdfreader(src); acrofields fields = reader.getacrofields(); // cp_1 name of check box field string[] values = fields.getappearancestates("isno"); stringbuffer sb = new stringbuffer(); (string value : values) { sb.append(value); sb.append('\n'); } return sb.tostring(); }
or take @ pdf using rups. go widget annotation , normal (/n
) appearance (ap
) states. in example /off
, /yes
:
Comments
Post a Comment