You can add a PDF to an AIR application by creating an HTMLLoader instance, setting its dimensions, and loading the path of a PDF.The following example loads a PDF from an external site. Replace the URLRequest with the path to an available external PDF.
import mx.core.Application;
public function loadPdfUI(path:String):void
{
if(hasAdobeReader())
{
var htmlloader:HTMLLoader = HTMLLoader.createRootWindow(true);
htmlloader.window.document.title="PDF CONTAINER - "+path;
htmlloader.window.document.width = Application.application.width;
htmlloader.window.document.height = Application.application.height;
var url:URLRequest=new URLRequest(decodeURIComponent(path));
htmlloader.x = 0; htmlloader.y = 0;
htmlloader.load(url);
}
}
private function hasAdobeReader():Boolean
{
return (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) ? true : false;
}
The hasAdobeReader() method is used to detect the Adobe Reader is in the system.
No comments:
Post a Comment