If you're seeing something other than Verdana, the Font is Graublau Sans Web by FDI fonts.info
Skills Required: Flex, ActionScript, Acrobat 9
One of the great new features of Adobe Acrobat 9 Pro and Pro Extended is the ability to add SFW based Rich Media Annotations (RMAs) developed in Flash or Flex. These SWF files can be placed in a PDF file using the new Flash Tool in Acrobat 9 and play using the built-in Flash Player. The built-in player provides greater security and consistency for Flash playback inside any PDF file. For those of you that attempted to use Flash in a PDF with earlier versions of Acrobat, you'll remember that the user experience wasn'tât all that great. Acrobat 9 provides tight integration between the PDF document and the RMAs well as other content types that run in the Flash Player such as FLV and H.264 encoded video.
There are two ways to play the RMA in a PDF file, on the page or in a floating window.
|
![]() When the RMA is played on the page, you are able to use the Acrobat commenting features to review and markup the interactive content. |
Acrobat's scripting language is JavaScript. In order to trigger events in an embedded RMA, you'll need to call the exposed ActionScript functions inside it. If you know how to communicate between an HTML page in a browser and the Flash browser plug-in, this will feel pretty familiar.
Three Steps to setting up the bridge from Acrobat JavaScript to ActionScript
To call the Flex method from Acrobat, you need to get a reference to the SWF object. You then call the method on that object, passing whatever parameters you want... just like with HTML.
Unlike HTML, you have no way to assign a name or ID to the SWF when placing the SWF into the PDF file using Acrobat. Instead, the Acrobat JavaScript SDK can be used to get a reference to the RMA that represents the SWF object on the page.
getAnnotsRichMedia returns an array of AnnotRichMedia objects for a given page. So if you only had one RMA on the first page of a document, the JavaScript to reference it would look like this...
RMA = this.getAnnotsRichMedia(0)[0]
Once you have a reference to the SWF, callAS calls into ActionScript with the ExternalInterface calling convention to an exposed method. In the attached example code, the "requestPhotos" method makes a request from the Flickr API. Using the same RMA object from the code above, calling the method from Acrobat would look like this if you were looking for images of "spring flowers".
RMA.callAS("requestPhotos", "spring flowers")
In the example PDF file linked below, the "Search" button contains the following code that takes the value of the "term" field and sends it to the RMA as long as the RMA is active. If the RMA is not active, you are alerted to activate it first. Look for this code in the "MouseUp" action of the "search" button.
RMA = this.getAnnotsRichMedia(0)[0]
if (RMA.activated == true)
{
RMA.callAS("requestPhotos", this.getField("term").value)
}
else
{
app.alert("The RMA must be activated first.")
}
To call Acrobat methods from the SWF, you'd use ExternalInterface.call just like you would with HTML. You can call any Acrobat method in the Acrobat JavaScript SDK. You can also call any methods that are in application level or document level JavaScripts. You can also use "eval" to send JavaScript into Acrobat from ActionScript and the return value of that method in Acrobat will be returned to your ActionScript method.
If you wanted your SWF to know how many pages were in the PDF file, you could use the following line of code.
var pages:int = ExternalInterface.call('eval', "this.numPages")
In the example PDF file linked below, the "credit" field gets populated by the RMA as you roll over the images. In the itemRenderer of the TileList mouseOver event, the following line gets executed. The first argument "eval" tells Acrobat to treat the second argument as JavaScript. The second argument concatenates a string to create the proper JavaScript to set the value of the "credit" field using the data object passed to the itemRenderer.
ExternalInterface.call("eval", "this.getField('credit').value = '"+data.credit+"'")
The Flickr RMA is a very basic example built on the Flickr RIA. It's simple but what it demonstrates is the foundation for doing far more interesting things with RMAs and Acrobat.
PDF Example using the Flickr RMA
Flickr RMA Project
Please take a look at the Yahoo Map example for a more exciting implementation.
Additional references:
Accessing Flex from JavaScript