13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 28: Adding PDF cont<strong>en</strong>t in AIR<br />

Adobe AIR 1.0 and later<br />

Applications running in Adobe® AIR® can r<strong>en</strong>der not only SWF and HTML cont<strong>en</strong>t, but also PDF cont<strong>en</strong>t. AIR<br />

applications r<strong>en</strong>der PDF cont<strong>en</strong>t using the HTMLLoader class, the WebKit <strong>en</strong>gine, and the Adobe® Reader® browser<br />

plug-in. In an AIR application, PDF cont<strong>en</strong>t can either stretch across the full height and width of your application or<br />

alternatively as a portion of the interface. The Adobe Reader browser plug-in controls display of PDF files in an AIR<br />

application. modifications to the Reader toolbar interface (such as controls for position, anchoring, and visibility)<br />

persist in subsequ<strong>en</strong>t viewing of PDF files in both AIR applications and the browser.<br />

Important: To r<strong>en</strong>der PDF cont<strong>en</strong>t in AIR, the user must have Adobe Reader or Adobe® Acrobat® version 8.1 or higher<br />

installed.<br />

Detecting PDF Capability<br />

Adobe AIR 1.0 and later<br />

If the user does not have Adobe Reader or Adobe Acrobat 8.1 or higher, PDF cont<strong>en</strong>t is not displayed in an AIR<br />

application. To detect if a user can r<strong>en</strong>der PDF cont<strong>en</strong>t, first check the HTMLLoader.pdfCapability property. This<br />

property is set to one of the following constants of the HTMLPDFCapability class:<br />

Constant Description<br />

HTMLPDFCapability.STATUS_OK A suffici<strong>en</strong>t version (8.1 or greater) of Adobe Reader is detected and<br />

PDF cont<strong>en</strong>t can be loaded into an HTMLLoader object.<br />

HTMLPDFCapability.ERROR_INSTALLED_READER_NOT_FOUND No version of Adobe Reader is detected. An HTMLLoader object<br />

cannot display PDF cont<strong>en</strong>t.<br />

HTMLPDFCapability.ERROR_INSTALLED_READER_TOO_OLD Adobe Reader has be<strong>en</strong> detected, but the version is too old. An<br />

HTMLLoader object cannot display PDF cont<strong>en</strong>t.<br />

HTMLPDFCapability.ERROR_PREFERRED_READER_TOO_OLD A suffici<strong>en</strong>t version (8.1 or later) of Adobe Reader is detected, but the<br />

version of Adobe Reader that is set up to handle PDF cont<strong>en</strong>t is older<br />

than Reader 8.1. An HTMLLoader object cannot display PDF cont<strong>en</strong>t.<br />

On Windows, if Adobe Acrobat or Adobe Reader version 7.x or above is running on the user's system, that version is<br />

used ev<strong>en</strong> if a later version that supports loading PDF is installed. In this case, if the value of the pdfCapability<br />

property is HTMLPDFCapability.STATUS_OK, wh<strong>en</strong> an AIR application attempts to load PDF cont<strong>en</strong>t, the older<br />

version of Acrobat or Reader displays an alert (and no exception is thrown in the AIR application). If this is a possible<br />

situation for your <strong>en</strong>d users, consider providing them with instructions to close Acrobat while running your<br />

application. You may want to display these instructions if the PDF cont<strong>en</strong>t does not load within an acceptable time<br />

frame.<br />

On Linux, AIR looks for Adobe Reader in the PATH exported by the user (if it contains the acroread command) and<br />

in the /opt/Adobe/Reader directory.<br />

The following code detects whether a user can display PDF cont<strong>en</strong>t in an AIR application. If the user cannot display<br />

PDF, the code traces the error code that corresponds to the HTMLPDFCapability error object:<br />

Last updated 6/6/2012<br />

550

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!