Expand my Community achievements bar.

SOLVED

Value Passing During openDoc()

Avatar

Level 2

Hi All,

I'm hoping someone here can help to solve my puzzle.

I'm currently developing my PDF form using Adobe LiveCycle ES2. From the main form, I have a button which open another PDF form using the app.openDoc() method. I'm wondering whether there is a way to pass some of the values from the main form to the second form?

For example, form A and form B both have a text field called "First Name". So when form A opens form B, the "First Name" text field in form B should be filled by the value pass in from form A.

Please help.

Regards,

Steven

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Steven,

You can by using the app.media() method.

There is an example here: http://assure.ly/qQivbm. I have been meaning to finish this off and post a blog. The last challenge is to get the image data into the AcroForm.

This is a portfolio with three forms. The first is a "broadcast" XFA form. This takes the inputs from the two text fields and the image field and uses the app.media method to "broadcast" the data as a package called "myData". You will see how we declare three variables (oName, etc) with the values of the objects in this form. 

The next form is a "receiving" XFA form. This looks for the "myData" package and if it exists, it sets the value of objects in this form, to the data in the package.

The last form is an AcroForm. This also looks out for myData, but at the moment it only processes the textfield data. I am working on the image data.

The script is in various events of a hidden object in the XFA forms (calculate event for the broadcasting form and docReady event for the receiving form). The AcroForm uses a document level script.

So, this is a working example. Note that for convenience I have packed it up in a portfolio, but you don't need to do this. It will also work for standalone files that are opened on the same computer.

As I say, I will probably get to finish this at some stage and post a full explanation.

Niall

View solution in original post

6 Replies

Avatar

Correct answer by
Level 10

Hi Steven,

You can by using the app.media() method.

There is an example here: http://assure.ly/qQivbm. I have been meaning to finish this off and post a blog. The last challenge is to get the image data into the AcroForm.

This is a portfolio with three forms. The first is a "broadcast" XFA form. This takes the inputs from the two text fields and the image field and uses the app.media method to "broadcast" the data as a package called "myData". You will see how we declare three variables (oName, etc) with the values of the objects in this form. 

The next form is a "receiving" XFA form. This looks for the "myData" package and if it exists, it sets the value of objects in this form, to the data in the package.

The last form is an AcroForm. This also looks out for myData, but at the moment it only processes the textfield data. I am working on the image data.

The script is in various events of a hidden object in the XFA forms (calculate event for the broadcasting form and docReady event for the receiving form). The AcroForm uses a document level script.

So, this is a working example. Note that for convenience I have packed it up in a portfolio, but you don't need to do this. It will also work for standalone files that are opened on the same computer.

As I say, I will probably get to finish this at some stage and post a full explanation.

Niall

Avatar

Level 2

Hi Niall,

This is exactly what I am looking for. Thanks a lot!!!

Another question to this app.media() method. I pressume the "broadcast" data are being stored in the computer memory in order for the other forms to be able to pick up the value. In this case, are we suppose to dispose the "myData" package upon closing the form? Is the garbage collector being triggered automatically as we close the form. I'm just worried that it will slow down the computer performance as more data are being broadcasted.

Thanks.

Regards,

Steven

Avatar

Level 2

Hi Radzmar,

Thanks for the reply. This is indeed a good piece of information.

Regards,

Steven

Avatar

Level 10

Hi Steven,

As you are aware the app.media method is intended for multimedia operations and we are hijacking it here to pass data.

app.media is an application method. Therefore myData is in Acrobat's memory and only persists as long as Acrobat is open. Once Acrobat is closed, myData is cleared. In addition myData gets overriden, if you make subsequent changes in the broadcast form. If you are concerned then this will simply null the parameters:

app.media.myData = null;

Please note that it is a work in progress. For example, in the AcroForm I have a button (no fill/no border), which I am trying to set its icon using the image data from the broadcast form. Without success at the moment, so there are a few errors happening behind the scenes.

Hope that helps,

Niall