Expand my Community achievements bar.

Who's My Daddy?

Avatar

Former Community Member
I would like to detect within the form if it is being displayed by Reader launched from my app (within a browser) or by Reader/Acrobat running seperately. One thought I had was to get the baseURL from the current document. I could parse the URL to see if I'm being launched by my application or by something else.



There don't seem to be any active documents. When I query app.activeDocs I get a length of 0. I've tried a number of different events, e.g FormReady, DocReady, initialize, etc. but I don't seem to get the Doc object. Am I missing something.



Alternatively, is there an easy way from within the form to tell how it was was launched.



Thanks
5 Replies

Avatar

Former Community Member
I believe the activeDocs only contain an array of all active documents within Reader which have the disclosed property set. Designer documents are not disclosed but the active doc object reference can be accessed using event.target which is available in any event.



As for checking if the document is being displayed in the browser vrs standalone acrobat product, there is a document property called external. So in desinger 7, use



if (event.target.external)

{

// Web Browser

}

else

{

// Acrobat/Reader Application

}



There is nothing in the XFA object model which can tell you whether or not the user is using standalone Reader. It can only detect versions and types of Acrobat products.



Note: the above property is Acrobat JS not XFA Object Model (in case you where wondering)

Avatar

Former Community Member
Thanks Dave. The external flag seems to be exaclty what I'm looking for. I was actually briwsing through the JavaScript Reference (as well as the XFA) but hadn't thought of using the event object to get to the doc object.



Do you know when the doc object is available. I tested event.target.external in a preSubmit event, no problem it was defined. But in the docReady or formReady events it doesn't seem to be bound yet - the message was 'InvalidGetError: Get not possible, invalid or unknown'. What's the earliest event at which I can test the external flag.



-- Mordechai

Avatar

Former Community Member
Not sure what is going on here. It is definitely a doc object being returned no matter what event I place the script on. However, there does seem to be a problem accessing properties during the init events phase from form:ready to calc. I tried some other events - some worked like URL, numPages, etc. and some did not external, layout, zoom, etc. It seems to fail when you try and access properties which have to in turn access the application. I'll check again tomorrow and see if there is any way around it.

Avatar

Former Community Member
Unfortunately, this looks like an issue with the handover between the XFA object model and Acrobat Doc Object. It is only available once init has been complete. The only way I got this to work is to use a timeout within Acrobat using the setInterval javascript function.