Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

Need help with PDF form - web page interaction. Quite urgent

badale2k7
Level 1
Level 1

Hello everyone,

I am trying to achieve interaction between a PDF dynamic form created with LiveCycle Designer ES2 and the web page it must be displayed into.

I have a web page containing an iframe in which the PDF form is opened, and would like to be able to access javascript functions inside the web page from the PDF form, and viceversa.

Is it possible? If so, how?

Does it have to do with embedding a FormBridge object in my form?

I did, but still can't find a way to make the javascript on the form communicate with the one on the web page, neither the other way round.

The issue is quite urgent, so I'll really appreciate any help!

Thanks in advance,

Alex

2 Replies
Steve_L_Walker
Level 10
Level 10

JavaScript in an HTML page can send a message to JavaScript in PDF content by calling the postMessage()method of the DOM object representing the PDF content.

See the Acrobat SDK JavaScript API for the hostContainer at http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp

and a somewhat complex sample at http://support.adobe.com/devsup/devsup.nsf/docs/54352.htm

Steve

badale2k7
Level 1
Level 1

Thankyou Steve,

that solved it!

By using the postMessage() method on the object that embeds the PDF in the web page and the FormBridge component on the form, I was able to send

messages from the page to the form.

I dug a bit more around postMessage, and also found out (should anyone need this for further reference) that communication in the opposite direction (from the form to the web page) can be achieved by calling the postMethod inside the form on the event.target.hostContainer object.

So, inside your PDF form, you could for example have javascript code like this:

event.target.hostContainer.postMessage("Hello World!");

The web page must in this case contain javascript code suitable for message handling. In particular, an event handler must be implemented for the <object> element embedding the PDF. Supposing this object has "PDFObj" as Id, the message handler code could be as follows:

function SetMessageHandler()

{

var PDFObject = document.getElementById("PDFObj");

    PDFObject.messageHandler =

    {

      onMessage: function(aMessage)

      {

         

          alert(aMessage);


          return true;

      },

      onError: function(error, aMessage)

      {

          alert(error.message);

      }

    };

}

...and on your <body> tag something like:

<body onload="setTimeout(SetMessageHandler, 1)">

Thanks again for the help!
Alex