Q: JavaScript does not seem to be running when I load a PDF programmatically. JavaScript works fine when I load a PDF through the toolbar open button on the QPDFViewerView.

A: JavaScript in Qoppa qPDF Toolkit requires an Android context to run within. When you open the document from the viewer, we automatically set the context.

If you are creating the document programmatically, i.e

pdfDoc = new PDFDocument(strFilePath, null);

the context is not getting set.

If you wish to load your PDF document before opening it in the viewer, you will need to use the constructor that takes the context as a parameter, i.e:

pdfDoc = new PDFDocument(new FilePDFSource(strFilePath), null, context);

where context is your current Activity.