Q:
I'm using PDFNet SDK for Windows Store Apps (NOT PDFNetJS), and am using the PDFDrawDemoJS sample as a starting point. But when I try to set the value of a PDF form field, I'm seeing a "type mismatch" error. The code looks like this:
doc = pdftron.PDF.PDFDoc(filestream);
doc.initSecurityHandler();
var field_to_update = doc.getField("my field");
field_to_update.setValue("my string");
What's going on?
A:
JavaScript doesn't have overloading of functions with the same number of parameters. Thus the JavaScript bindings for PDFNet SDK for Windows Store Apps only expose a single version of setValue, the one that takes in an SDF Obj. So it order to set the value of the field to a string, you need to instantiate an SDF Str (a subclass of Obj) and pass that in instead:
var str_obj = doc.createIndirectString("my string");
field_to_update.setValue(str_obj);