Why am I seeing a "Type mismatch" error when calling setValue from JavaScript?

20 views
Skip to first unread message

Aaron

unread,
Dec 11, 2015, 2:28:43 PM12/11/15
to PDFTron PDFNet SDK
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);



Reply all
Reply to author
Forward
0 new messages