These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Newbie question about functions.

jasondeegan
Registered: Feb 5 2008
Posts: 21
Answered

I have a PDF I just wrote (started from scratch) and opened it in LiveCycle 8.0. I added a button that would this.submitForm and another that would this.closeDoc. Upon opening the document in Acrobat and enabling the JS debugger, it tells me closeDoc is not a function. Same for submitForm.

What step am I missing to get simple JS to work?

Thanks much!

Jason

My Product Information:
Acrobat Pro 8.1.1, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Functions can have required, optional or no parameters passed but the format requires the parenthesis at the end of a function name.

this.closeDoc();

You may have some to build a trusted function to get this work and the closeDoc() function will not work in the Acrobat/Reader web plugin.

George Kaiser

jasondeegan
Registered: Feb 5 2008
Posts: 21
A trusted function?

I'm just following the JS API I downloaded from Adobe and it's not working.

Any other suggestions?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Any error messages?

From Version 8.0 JS API Reference page 28=76:

Example 1

From the console, close all open documents.

var d = app.activeDocs;
for( var i in d ) d[i].closeDoc();

The following code can be executed as a mouse-up action from an open document. It closes all disclosed open documents. The code is designed to close the active document last so that the execution of the code will not be abruptly terminated.

var d = app.activeDocs;
for( var i in d )
if( d[i] != this ) d[i].closeDoc();
if ( this.disclosed ) this.closeDoc();


The JS API is written for Acrobat Forms not LiveCycle Designer.

References to fields and documents is different for LiveCycle Designer.

var this = event.target; // get the LiveCycle Designer target doc
this.closeDoc(true); // close do not save changes

George Kaiser

jasondeegan
Registered: Feb 5 2008
Posts: 21
I ran this code on the mouseup event of a new button:

app.alert('jason');
var d = app.activeDocs;
for( var i in d )
if( d[i] != this ) d[i].closeDoc();
if ( this.disclosed ) this.closeDoc();

it gives me the alert('jason') message, but it doesn't do anything else.

At least there's no error.

Is there a LiveCycle API somewhere? If not, should I use Forms instead? (I'm looking to save a copy of a PDF back to a server as well as use an FDF to save the data)

I REALLY appreciate your assistance.

Jason
jasondeegan
Registered: Feb 5 2008
Posts: 21
Here's working code:

var myDoc = event.target;
myDoc.closeDoc();

Looks like the JS API is indeed for forms and LiveCycle is different. Adobe's done a very poor job of differentiating LiveCycle and Acrobat Forms.