JavaScript is supported in Qoppa’s Android PDF toolkit, qPDF Toolkit.
How is JavaScript used in PDF documents?
Mostly, JavaScript is used in interactive PDF forms in field actions to calculate the value of fields, validate field data to prevent invalid entry and format special fields such as dates, ssn, postal codes, phone numbers, etc… JavaScript can also be associated with other actions such as the Open Document action, for instance to prompt the user for data or silently print the document.
Jar File Needed for JavaScript Support
To support JavaScript in your application, make sure to include the following jar file: js-14.jar, which contains JavaScript classes and needs to be accessible to our toolkit.
How to turn on JavaScript
To turn JavaScript on, for all JavaScript-enabled PDF forms, make the following static call before loading any PDF form:
JavaScriptSettings.setJSEnabled(JavaScriptSettings.ALWAYS); |
Full Sample Code
package com.qoppa; import android.app.Activity; import android.os.Bundle; import com.qoppa.notes.QPDFNotesView; import com.qoppa.notes.settings.JavaScriptSettings; public class JavaScriptActivity extends Activity { public QPDFNotesView notes; protected void onCreate(Bundle bundle) { super.onCreate(bundle); JavaScriptSettings.setJSEnabled(JavaScriptSettings.ALWAYS); notes = new QPDFNotesView(this); notes.setActivity(this); setContentView(notes); } } |
JavaScript Support
See List of JavaScript Functions Supported