Recently in Rich Media Annotations Category

Setting the Size of the Rich Media Floating Window

| 1 Comment
Share

Skip down to here if you read my last post

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 interactive SWF content developed in Flash or Flex. SWF files can be placed in a PDF using the new Flash Tool in Acrobat 9 and play using the built in Acrobat 9 Flash Player rather than the external one that your browser and desktop use. The built-in player provides greater security and consistency for SWF playback inside any PDF with that type of content. For those of you that attempted to use SWF in earlier versions of Acrobat, you remember that the user experience wasn’t all that great. Acrobat 9 provides tight integration between the PDF document and SWF as well as other content types that run in the Flash Player such as FLV and H.264 encoded video.

Read “Add multimedia files to a PDF” to learn how to add SWF content to PDF files using the new Rich Media Annotation rather than the legacy multimedia object.

Setting the Size of the Rich Media Floating Window
In addition to the built-in Flash player providing greater security and consistency for SWF playback, it also has built in functions that take advantage of features found only in Acrobat and Reader. The remainder of this article discusses how to control the size of the window when your SWF is not playing on the page.

The built in function "multimedia_setWidgetViewSize" can be used to respond to different states or layouts of your SWF application. The parameters are pretty simple; width and height. Unfortunately, you cannot control the initial location of the window. See the example PDF below and sample MXML file.

Example PDF

Sample Flex Application

Saving the State of SWF Content in Acrobat 9

| 5 Comments
Share

Skip down to here if you read my last post

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 interactive SWF content developed in Flash or Flex. SWF files can be placed in a PDF using the new Flash Tool in Acrobat 9 and play using the built in Acrobat 9 Flash Player rather than the external one that your browser and desktop use. The built-in player provides greater security and consistency for SWF playback inside any PDF with that type of content. For those of you that attempted to use SWF in earlier versions of Acrobat, you remember that the user experience wasn’t all that great. Acrobat 9 provides tight integration between the PDF document and SWF as well as other content types that run in the Flash Player such as FLV and H.264 encoded video.

Read “Add multimedia files to a PDF” to learn how to add SWF content to PDF files using the new Rich Media Annotation rather than the legacy multimedia object.

Saving the State of SWF Content in Acrobat 9
In addition to the built-in Flash player providing greater security and consistency for SWF playback, it also has built in functions that take advantage of features found only in Acrobat and Reader. The remainder of this article discusses how to keep the state of your SWF content persistent in the PDF so that when the file is saved then reopened, your SWF content looks the same.

To store the state of your SWF content, use the built in "multimedia_saveSettingsString" function
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 simply storing the value of the HSlider called "size". For more complex applications, I recommend using an XML object to store the variables and then casting it to a string before saving it.
I also recommend saving the state every time a variable that you want to track gets changed. Acrobat will fire a "WillSave"
event that you can attach JavaScript to that can be used to call the "multimedia_saveSettingsString" but the internal
plumbing must be added to the PDF for that to work. By saving the settings on every change, all of the work can be done in ActionScript rather than a combination of ActionScript and JavaScript.

var result:Object = ExternalInterface.call("multimedia_saveSettingsString", size.value.toString());

Restoring the State of SWF Content in Acrobat 9
To resore the settings, add code that uses the built in function "multimedia_loadSettingsString" to the creationComplete function.
In the example code below, if the widget was just placed and settings were never saved (result returns null), it uses the defaults programmed into the application.
If the call returns an object, I use it to restore the state. Again, for more complex use cases, an XML object that is cast as a string can be used.

var result:Object = ExternalInterface.call("multimedia_loadSettingsString");
if (result)
{
size.value = int(result.toString());
}

Open the example PDF below and move the slider to adjust the size of the red square. Save the file. Close it, then reopen it. You’ll see that the size of the red square is the same as it was when you saved the file.

  Example PDF

Sample Flex Application

 

Enabling Commenting of SWF content in Acrobat 9

| No Comments
Share

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 interactive SWF content developed in Flash or Flex. SWF files can be placed in a PDF using the new Flash Tool in Acrobat 9 and play using the built in Acrobat 9 Flash Player rather than the external one that your browser and desktop use. The built-in player provides greater security and consistency for SWF playback inside any PDF with that type of content. For those of you that attempted to use SWF in earlier versions of Acrobat, you remember that the user experience wasn’t all that great. Acrobat 9 provides tight integration between the PDF document and SWF as well as other content types that run in the Flash Player such as FLV and H.264 encoded video.

Read “Add multimedia files to a PDF” to learn how to add SWF content to PDF files using the new Rich Media Annotation rather than the legacy multimedia object.

There are two ways to play the SWF widget or in Acrobat, on the page or in a floating window. The floating window has certain advantages when you need the SWF to be present regardless of what page you are on in the PDF. However, when the SWF is played on the page, you are able to use the Acrobat commenting features to review and markup the interactive content.

Review and Markup SWF content using Acrobat 9
By default and no additional coding in the SWF, you can add a comment to any SWF content placed on a PDF page. When another user wants to review your feedback by clicking on your comment in the “Comments” navigation panel, a bitmap of the state of the SFW content at the time the comment was made will be displayed with your markup sitting on top. This alone can help speed up designer/developer workflows even if the ultimate destination of the SWF is a web page and not a PDF.

But… with just a little coding, we can take things a huge step further.
In addition to the built-in Flash player providing greater security and consistency for SWF playback, it also has built in functions that take advantage of features found only in Acrobat and Reader. The remainder of this article discusses just two of those functions but there are more, stay tuned for future articles.

Storing the state of your SWF when a user adds a comment
Acrobat sends your SWF content a “multimedia_getState” callback when a user adds a comment. Your job is to collect up all the variables you need to get back to this state into a single string. When you return this string from the function called by the “multimedia_getState” callback, Acrobat will store the string in the annotation’s properties.  In the attached code sample, I’m simply storing the content of the text field. For more complex applications, I recommend using an XML object to store the variables and then casting it to a string before returning it. You’d then cast it back to XML when you need to restore the state.

Restoring the state of your SWF when a user clicks on a comment in the “Comments” navigation panel
When a user selects a comment from the “Comments” navigation panel that belongs to your SWF content, Acrobat sends your SWF a “multimedia_setState” callback along with the string that was passed to Acrobat when the comment was made. Your job is to take the information in the string and use it to set the variables you need in order to restore the state that the SWF was in when the comment was created. By default, the initial representation is still the bitmap that I referred to above but when you click back into the SWF content, you’ll see that the variables are all restored to what they were (assuming you set them back correctly from the string).

Implementation
Take a look at the attached sample Flex application to see how this works. You’ll see that I’m adding callbacks for “multimedia_getState” and “multimedia_setState” in my creationComplete() function. The rest is basic Flex code.

The PDF example already has some comments in it and is Reader extended for commenting so if you just have Reader 9, you can still see how this works.

Example PDF

Sample Flex Application

JavaScript Control of Video in Acrobat 9

| No Comments
Share

One of the great new features in Adobe Acrobat 9 is the ability to add Flash Video or H.264 encoded video to any PDF page. If you have Acrobat Pro Extended, it will automatically convert virtually any video format into Flash video for you when you import the video. You can also reference URLs to video that will stream from the web.

Video Playbar Image

Adobe Acrobat 9 automatically adds playback controls called a “skin”, when you add a video to a PDF page similar to the one at the bottom of the the image above.

However, if you want to control playback via buttons, links or other navigational features of PDF, you can use JavaScript to control the video too and even set the skin style to “none”. The reason we can do this is because the skin is actually a Flash (SWF) wrapper around the video. The Adobe supplied skins have built in ActionScript functions that can be accessed via Acrobat JavaScript. The list of those functions and a link to an example file is below. You don’t actually need to have any experience with ActionScript to use the functions but a basic understanding of Acrobat JavaScript would be helpful.

Note: Because the skins are simply Flash files, you can further customize the skins and even create your own using Adobe Flash CS3. Read Modifying Skins to see how.

ActionScript Playback Control Functions:
multimedia_play
multimedia_pause
multimedia_rewind
multimedia_nextCuePoint
multimedia_prevCuePoint
multimedia_seek, time (measured in seconds)
multimedia_mute
multimedia_volume, num (0<= num <= 1)

Use:
You need to begin by creating an object that represents the specific Rich Media Annotation that contains the video. Use the new getAnnotsRichMedia method to do that. this.getAnnotsRichMedia( pageNum:Integer ) returns an array of AnnotRichMedia objects for a given page but you can get just the one you are interested in by also giving the method the index number of the annotation. So your code might look like this for a single video on the first page of the PDF.

var annot = this.getAnnotsRichMedia(0)[0];

Then you can simply use the callAS (Call ActionScript) method and pass in the name of the function you want the skin to perform. Of course, you might want to add a line of code that will activate that annotation before playing if it is not already activated. To begin playing a video, your code might look like this.

if (!annot.activated) annot.activated=true;
annot.callAS(“multimedia_play”);

To see the code in the example file, open the file in Acrobat and turn on the “Advanced Editing” toolbar then choose the “Select Object” tool (the big black arrow) and select one of the buttons below the video box. Review the JavaScript in the MouseUp action in the Actions tab.

PDF icon Sample with Play, Pause and Rewind buttons.