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.

Make sure to include js-14.jar in the classpath
Make sure to include the JavaScript jar  js-14.jar in the classpath

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