Accessibility

TechNote

Loading a Password Protected PDF in a Flex based AIR application

Issue


Loading a password protected PDF document inside a Flex based AIR application from the creationComplete event of the WindowedApplication causes the AIR application to hang or not render properly if you click the Cancel button on the PDF password prompt.

Solution


Instead of loading the PDF from the creationComplete event, use the invoke event from the WindowedApplication.

Note the use of the invoke argument in the WindowedApplication:

<mx:WindowedApplication 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    width="600" 
    height="600" 
    invoke="loadPDF()">

Here is the function that loads the PDF into an HTML component:

private function loadPDF():void {
    // check that the client is able to open PDFs 
    if (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) {
        var request:URLRequest = new URLRequest("test.pdf"); 
        var pdf:HTMLLoader = new HTMLLoader(); 
        pdf.height = 500; 
        pdf.width = 500; 
        pdf.load(request); 
        myHTML.location = pdf.location; 
    } 
    else { 
        trace("Unable to open PDF docs!"); 
    } 
}

Here is the HTML component which has its location set in the loadPDF() function above:

<mx:HTML id="myHTML" width="500" height="500"/>

Additional information


http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS5b3ccc516d4fbf351e63e3d118666ade46-7eb4.html

http://cookbooks.adobe.com/post_How_do_I_use_command_line_arguments_with_my_AIR_ap-8003.html

 

 

 

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support

Document Details

ID:cpsid_53161
OS:Windows (All)

Products Affected:

air
flex