Expand my Community achievements bar.

Detect if fillable form is open in Acrobat (as opposed to Reader or web browser)

Avatar

Former Community Member

I have a fillable form that is Reader Extended (so it can be saved from Adobe Reader). After a user fills in the form, he clicks a submit button that sends a data stream to a servlet. The servlet embeds this data as XML in another version of the form, converts the form to be PDF/A compliant, and returns the new PDF/A form with embedded data. That all works fine when the fillable form was open in either Reader or a web browser. But if the user has the fillable form open in Acrobat when he clicks the submit button, the embedded data is stripped out of the PDF/A form that's returned by the servlet.

It's not a problem if the user fills in the data while the form is open in Acrobat, as long as he closes the form and opens it in Reader or a web browser before clicking the submit button.

Is there a way to detect if the fillable form is open in Acrobat (perhaps in the preSubmit event?) so I can display a message warning the user to save and close the form, and then open it in Reader or a web browser before clicking the submit button?

8 Replies

Avatar

Former Community Member

Thanks, Srini, this told me how to get the name of the viewer (ex. Reader vs. Exchange-Pro). Unfortunately, viewerType doesn't seem to distinguish between the form being open in just plain Acrobat versus being open in Internet Explorer - the viewer type is the same for both (Exchange-Pro).

It looks like there's a userAgent value that can distinguish between Acrobat and a browser - is this a value that I can access from a Designer form?

Thanks.

Alice

Avatar

Level 10

The below script can provide you whether it is Acrobat or not..

xfa.host.name

Thanks

Srini

Avatar

Former Community Member

I added the following code to my submit button, but it gives me the same appType and host.name values for IE and Acrobat, so I can't tell them apart:

var

viewerType = xfa.host.appType;

var

viewerName = xfa.host.name;

xfa.host.messageBox("Viewer is "

+ viewerType);

xfa.host.messageBox("Host is "

+ viewerName);

viewerType is Exchange-Pro

viewerName is Acrobat

Avatar

Level 10

You need xfa.host.version.

I recommend downloading a copy of the LiveCycle Designer Scripting Reference - you'll find it all in there.

Avatar

Level 8

I also want to find out if the PDF form was opened in Acrobat or Browser.

I tried xfa.host.name and I am always getting "Acrobat". For example, if I open the PDF from IE using Ctrl-O and display the value of xfa.host.name I always get "Acrobat",

I think the best way is to check the doc.path or doc.URL (using event.target). If the path or URL starts with "http://" then most likely the PDF form was opened from the web server using a browser.

Appreciate your feedback.

Tarek

Avatar

Level 7

xfa.host.name will always give you the name of the XFA renderer (e.g. Acrobat, Reader),not the container (standalone, IE, Firefox). Therefore, your approach makes sense.

Avatar

Level 8

Thank you jnicholas330​ !

As per this article I should get the browser name.

However, my approach is working fine so far.

Tarek