Vladimir
Vladimir

Reputation: 173

Show pdf in Flex air

I went through a document at Adobe Livedocs that describes working with pdf: http://livedocs.adobe.com/flex/3/html/help.html?content=PDF_1.html

But I'm stuck with it and can't get it to work.

Can anyone help me?

thanks Vladimir

Upvotes: 0

Views: 2358

Answers (1)

Mircea Grelus
Mircea Grelus

Reputation: 2915

Adobe Air relies on the Adobe Reader browser plugin to render the PDF files. So a user of the AIR application will have to have Adobe Reader installed. This also means that any customization that might have been done by the user to the Adobe Reader interface will be reflected in their AIR app.

This being said, do you have Adobe Reader installed? It has to be at least version 8.1.

You could put a breakpoint in the code below where it checks the pdfCapability and it will tell you whether it supports pdf.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" 
    creationComplete="onCreationComplete()">

    <mx:Script>
        <![CDATA[
            import mx.core.UIComponent;

            public function onCreationComplete():void
            {
                if(HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK)
                {
                    var htmlLoader:HTMLLoader = new HTMLLoader();
                    var pdfUrl:URLRequest = new URLRequest("http://www.adobe.com/devnet/flex/pdfs/getting_started_with_Flex3.pdf"); 
                    htmlLoader.load(pdfUrl);
                    htmlLoader.width = 1024;
                    htmlLoader.height= 768;
                    pdfComponent.addChild(htmlLoader);
                }
            }
        ]]>
    </mx:Script>
    <mx:VBox>
        <mx:Label text="pdf below:" />
        <mx:UIComponent id="pdfComponent"  />
    </mx:VBox>  
</mx:WindowedApplication>

Upvotes: 1

Related Questions