A recent project was creating an interactive PDF conference registration form for a non-profit organization.
Up till then they used a non-interactive PDF that members/attendants had to print, fill in with a pen, and either scan and e-mail or send by snail mail.
Due to the members/attendants' high average age there was some fear that withe the new interactive form we might be spending many hours on support calls.
That is why I wrote a simple "PDF Form Test", allowing members to check if their software is capable of handling PDF forms at all, and if not explaining them to use the old print-pen-snail mail technique.
It was created using PDFill PDF Form Maker.
Initially, it will show the following text:
You cannot fill in interactive PDF forms with the current computer, software and settings.
Use alternative software or change your software's settings, or print the form on paper and send (a scan of) the completed paper form by mail.
If the PDF reader is capable of handling Adobe JavaScript, however, this text is immediately replaced by the following text (with the actual software name and version), and a hidden "Print" button is made visible:
Congratulations!
You are using PDF-XChange Editor version 10.1.3.383.
This software can be used to fill in interactieve PDF forms without restrictions.
Click the "Print" button to send these test results to a printer.
Though not visible in the normal view, some extra debugging info will be included in the printed output:
The code to achieve this is executed when the document is opened:
var debugmsg = "";
var newmsg = "";
var viewername = "an unknown program";
var viewerver = "";
var advforms = false;
if ( typeof app.viewerType != "undefined" )
{
debugmsg += "app.viewerType = " + app.viewerType;
debugmsg += "\napp.viewerVersion = " + app.viewerVersion;
if ( typeof app.pxceInfo != "undefined" )
{
debugmsg += "\napp.pxceInfo.name = " + app.pxceInfo.name;
debugmsg += "\napp.pxceInfo.variation = " + app.pxceInfo.variation;
debugmsg += "\napp.pxceInfo.platform = " + app.pxceInfo.platform;
debugmsg += "\napp.pxceInfo.version = " + app.pxceInfo.version.join( "." );
debugmsg += "\napp.pxceVersion = " + app.pxceVersion.join( "." );
}
if ( typeof app.isFoxit != "undefined" )
{
debugmsg += "\napp.isFoxit = " + app.isFoxit;
}
if ( typeof app.plugIns != "undefined" )
{
var plugins = app.plugIns.join( "\n " ); // 25 tabs to align plugins
if ( plugins == "" )
{
plugins = "none";
}
debugmsg += "\napp.plugIns = " + plugins;
}
if ( app.viewerType == "Exchange" )
{
viewername = "Acrobat Standard";
advforms = true;
viewerver = " version " + app.viewerVersion;
}
else if ( app.viewerType == "Exchange-Pro" )
{
viewername = "Acrobat Pro, Foxit PDF Reader or PDF-XChange, or other software spoofing as Acrobat Pro";
advforms = true;
viewerver = " version " + app.viewerVersion;
if ( typeof app.pxceInfo != "undefined" )
{
viewername = "PDF-XChange " + app.pxceInfo.name;
viewerver = " version " + app.pxceInfo.version.join( "." );
}
else if ( typeof app.isFoxit != "undefined" )
{
if ( app.isFoxit.indexOf( "Foxit" ) > -1 )
{
viewername = app.isFoxit;
}
}
else if ( typeof app.plugIns != "undefined" )
{
if ( app.plugIns.join( ).indexOf( "ADBE" ) > -1 )
{
viewername = "Acrobat Pro";
}
}
}
else if ( app.viewerType == "eXPertPDF" )
{
viewername = "VisageSoft Expert PDF Reader";
viewerver = " version " + app.viewerVersion;
}
else if ( app.viewerType == "Nitro-Reader" )
{
viewername = "Nitro PDF Reader";
advforms = true;
viewerver = app.viewerVersion;
}
else if ( app.viewerType == "Reader" )
{
viewername = "Adobe Reader";
advforms = true;
viewerver = " version " + app.viewerVersion;
}
else if ( app.viewerType == "PDF.js" )
{
viewername = "Mozilla Firefox";
viewerver = " version " + app.viewerVersion;
}
else if ( app.viewerType == "pdfium" )
{
viewername = "Brave, Chrome, Edge, Opera, or another browser";
viewerver = " version " + app.viewerVersion;
}
if ( advforms )
{
newmsg += "Congratulations!\n";
}
newmsg += "You are using " + viewername + viewerver + ".\n";
if ( advforms )
{
newmsg += "This software can be used to fill in interactieve PDF forms without restrictions.\n\n";
}
else
{
newmsg += "This software can be used to fill in basic interactieve PDF forms with some restrictions, i.e. calculations will most likely contain errors.\n";
newmsg += "Using alternative software that is capable of performing calculations is recommended.\n\n";
}
newmsg += "Click the \"Print\" button to send these test results to a printer.";
this.getField( "Result" ).value = newmsg;
this.getField( "DebugHeader" ).display = display.noView; // hidden in normal view, but visible on printout
this.getField( "DebugResult" ).display = display.noView;
this.getField( "DebugResult" ).value = debugmsg;
this.getField( "Button" ).display = display.noPrint; // visible but not printed
}
Notes: | 1: | The test is not 100% reliable on smartphones, some "unknown" PDF viewer apps may still display an empty form. |
2: | Saving the test results as PDF is of no use, since it will remain an interactive PDF showing the results for the computer that opens the saved file. That is why I chose to use a "Print" button: with a PDF printer you can still save the results as a "static" PDF file. |
The download contains both English and Dutch test PDFs, and the PDFill project files as well, allowing you to modify the files yourself (e.g. translate into other languages?)
Some objects available in JavaScript to try and detect the exact PDF Viewer program:
JavaScript | Returns | Application | Form Fill Capabilities | Remarks |
---|---|---|---|---|
app.viewerType | Exchange | Acrobat Standard | Good | |
Exchange-Pro | Acrobat Pro, Foxit PDF Reader, PDF-XChange Editor | Good | Though of little use to detect the exact viewer, still useful to check if the viewer is capable of handling forms | |
eXPertPDF | VisageSoft Expert PDF Reader | Limited | ||
Nitro-Reader | Nitro PDF Reader | Good | ||
Reader | Adobe Reader | Good | ||
PDF.js | Mozilla Firefox | Limited | ||
pdfium | Brave, Chrome, Edge, Opera, other browsers | Limited | ||
app.viewerVersion | version (string) |
Viewers that spoof their app.viewerType value (e.g. Foxit, PDF-XChange) may also spoof their app.viewerVersion value |
||
app.pxceInfo.name | Editor | PDF-XChange Editor | Good | Available in PDF-XChange only, use
if ( typeof app.pxceInfo != 'undefined' ) { ... }
to prevent the script from crashing in non-PDF-XChange viewers.app.pxceVersion returns an array of four numbers that represent the Editor version.app.pxceInfo returns an object with properties version (identical to app.pxceVersion ), variation, name, and platform. |
app.pxceVersion | version (array) |
|||
app.pxceVersion.join('.') | version (string) |
|||
app.isFoxit | foxit name and version | Foxit PDF Viewer | Good | Available in Foxit PDF Viewer only, useif ( typeof app.isFoxit != 'undefined' ) { to prevent the script from crashing in non-Foxit viewers |
app.plugIns.join().indexOf('ADBE') > -1 | true if Adobe software | Adobe Reader, Acrobat Standard, Acrobat Pro | Good | Available in Adobe, Foxit and PDF-XChange software, but not in browsers and file managers, use
if ( typeof app.plugIns != 'undefined' ) { ... }
to prevent the script from crashing in browsers and file managers |
Note: | PDF viewers that do not support JavaScript (e.g. Slim PDF Reader, SumatraPDF), or that don't support the app.viewerType object (e.g. Javelin PDF Reader) cannot be identified, of course.That is why the PDFFormTest PDF by default states that the viewer cannot be used to fill in forms, and if JavaScript and the app.viewerType object are supported, it will overwrite that statement. |
page last modified: 2024-01-04; loaded in 0.0047 seconds