15.5. PDF Support

The HTML component will support the display of Adobe PDF only if the installed version is Acrobat Reader 8.1 or later. You can test for this by using the static pdfCapability property of the HTML class. The easiest way to confirm that a user can load PDF files into the HTML component is to test HTML.pdfCapability against the STATUS_OK static property of the HTMLPDFCapability class. Listing 15-12 shows a simple function that will check to see if the user has the correct version of Adobe Reader. If Reader is found, a sample PDF is loaded; if not, the user is shown the Adobe Reader download page. The results can be seen in Figures 15-9 and 15-10.

Example 15-12. The use of the pdfCapability property
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    creationComplete="testPDFCapability()" width="825" height="625">
    <mx:Script>
        <![CDATA[
        private function testPDFCapability():void{
            if(HTML.pdfCapability== HTMLPDFCapability.STATUS_OK){
              html.location="http://www.everythingflex.com/assets/pdfs/sample.pdf";
            }else{
              html.location="http://www.adobe.com/products/acrobat/readstep2.html";
            }
        }
        ]]>
    </mx:Script>
    <mx:HTML id="html" width="800" height="600"/>
</mx:WindowedApplication>
Figure 15-9. The Chapter15_PDF application directing the user to the Reader download page when HTML.pdfCapability fails.
Figure ...

Get Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.