Home
eMail

If you're seeing something other than Verdana, the Font is Graublau Sans Web by FDI fonts.info

Working with Rich Media Annotations
Updated 11/13/2009

Enabling Review and Markup with State Save

Skills Required: Flex, ActionScript, Acrobat 9

The Basics of SWF in PDF

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.


The floating window has certain advantages when you need the RMA to be present regardless of what page you are on in the PDF file.


When the RMA is played on the page, you are able to use the Acrobat commenting features to review and markup the interactive content.

Read “Add multimedia files to a PDF” to learn how to add RMAs to PDF files using the new Flash tool rather than the legacy multimedia object.

Saving SWF State Information in Acrobat 9

Default Comment and Review Behavior of RMAs
With no additional coding in the SWF, you can add a comment to any RMA placed on a PDF page. When another user clicks on your comment in the “Comments” navigation panel, a bitmap of the way the RMA looked at the time the comment was made will be displayed with your markup sitting on top. No variables in the active RMA will be changed. This alone can help speed up designer/developer workflows even if the ultimate container for the SWF is an HTML page and not a PDF file. With just a little coding, however, we can take things a huge step further and allow variables within the RMA to be managed by Acrobat.

In addition to the built-in Flash player providing greater security and consistency for Flash content in PDF files, it also has built-in functions that take advantage of features found only in Adobe Acrobat and Adobe Reader. The first half of this article discusses how to keep the state of your Flash content (RMA) persistent in the PDF so that when the file is saved then re-opened, your RMA looks the same. The second half discusses how you can do the same sort of thing except you store the state in a comment that was made on top of the RMA.

Saving the State of an RMA in the PDF file
To store the state of your RMA, use the built-in "multimedia_saveSettingsString" command and pass in a string that contains all of the variables you need to recreate the state you are saving. In the example file below, I'm using an XML object to store the variables required to reproduce the layout of the pods and the slice of the pie that may be exploded. You'll see in the attached Flex project the line where I save the settings which are collected into an XML Object called "layoutSettings".

var result:Object = ExternalInterface.call("multimedia_saveSettingsString", layoutSettings.toString())

Restoring the State of an RMA in the PDF file
To restore the settings, add code that uses the built-in command "multimedia_loadSettingsString" to the creationComplete (or similar) event. Acrobat will pass back to your SWF the same string that was saved with the "multimedia_saveSettingsString" command.

In the example code below, if the RMA was just added to the PDF file and settings were never saved (returns null), it uses the defaults programmed into the RMA. If the call returns an object, I cast the string to an XML Object and use the stored settings to restore the layout of the RMA.

var result:Object = ExternalInterface.call( "multimedia_loadSettingsString" );
if (result)
{
	//a string was returned from Acrobat
	layoutSettings = XML(result.toString());
	adjustLayout();
}
else
{
	//no string was returned from Acrobat
	getDefaults();
}

Saving the State of an RMA to a Comment
When your RMA is active and a user adds a comment on top of it, an ActionScript ExternalInterface call is made to the function "multimedia_getState" with no arguments. The "multimedia_getState" function should have a callback and the callback should return a string. Acrobat will store the string in the RMA's properties.

Restoring the State of an RMA from a Comment
When a user selects a comment that belongs to your RMA, an ActionScript ExternalInterface call is made to the "multimedia_setState" function, where the first argument is the same string that was stored by "multimedia_getState". The "multimedia_setState" function should have a callback and the callback should return "true" if the string isn't "null". You can then use this string to restore the state similar to what I mentioned above.

The example PDF file below demonstrates these capabilities.

Using the Demo File

Saving the State of the RMA into the PDF file:
To see how the RMA behaves between Adobe Acrobat or Adobe Reader sessions...

  1. Click around on the dashboard below until it looks that way that you want it.
  2. Save the PDF file.
  3. Close the PDF file.
  4. Reopen it.

You should see the RMA display the same configuration as when you saved the file.

Saving the State of the RMA into a Comment:
To see how the RMA behaves when using comments...

  1. Click around on the dashboard below until it looks that way that you want it.
  2. Use any of the Acrobat Commenting tools to add a comment. Be sure the mouse is over the RMA. You’ll know when it is because the RMA will be outlined in green.
  3. After you’ve made a comment, click around again then add another comment.
  4. Repeat this as many times as you like.
  5. Open the comment pane (yellow balloon in the bottom left corner of the Acrobat UI)
  6. Click on any of the comments.

You should see that Acrobat passes the state information back to the RMA restoring it to the same state that it was in when the comment was made.

Open the Example PDF file.
Download the Flex Project for the RMA in the example.

Comments: