此代码无法在Mac OS上的AIR应用程序中打开PDF文件。但是同样的代码在windows中运行。 我安装了adobe acrobat reader。但我仍然面临MAC OS错误
protected function button2_clickHandler(event:MouseEvent):void
{
if (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK){
var FileDir:File =new File();
var FilePath:String = "";
try
{
// Open browser for choose pdf file for open
FileDir.browseForOpen("Open As [Only supports .PDF extension with file name.]");
FileDir.addEventListener(Event.SELECT, readFromDirectory);
//htmlLoader.parent.removeChild(htmlLoader);
}
catch (error:Error)
{
trace("Failed:", error.message);
}
//***** Browse event complete *****
function readFromDirectory(event:Event):void
{
try
{
var newFile:File = event.target as File;
FilePath = newFile.nativePath;
var url:URLRequest = new URLRequest(FilePath); //URL to the file
htmlLoader.width = 700; //width of the content area
htmlLoader.height = 450; //height of the content area
htmlLoader.load(url);
//wrapping into UIComponent
holder = new UIComponent();
holder.addChild(htmlLoader);
addElement(holder);
}
catch(err:Error)
{
trace("file not in correct format");
}
}
}
}
答案 0 :(得分:0)
尝试在Mac上安装Acrobat Reader。