【问题标题】:Open embedded PDF from AIR从 AIR 打开嵌入的 PDF
【发布时间】:2011-06-07 15:57:08
【问题描述】:

推荐的解决方案是使用 Acrobat(或任何其他阅读器)打开嵌入的 文档。我关注了一个类似的问题openWithDefaultApplication fails on files in application folder,但这似乎不起作用。

var filename = "John_Doe-tax_return_2011.pdf"; // = my filename

var realFile:File = File.applicationDirectory.resolvePath(filename); 
var tempFile:File = File.createTempFile(); 

    realFile.copyTo(tempFile,true); 
    tempFile.openWithDefaultApplication();

我都测试过了,所以不是目录问题

trace(tempFile.extension) // > tmp (?? tempFile.extension = "pdf" doesn't works)
trace(realFile.exists)    // > true (original pdf-document exists!)

【问题讨论】:

  • 如果您找到了解决方案,您应该将其发布为答案,而不是编辑您的问题。如果它比建议的其余解决方案更好,您也可以选择它作为答案。

标签: pdf flash actionscript-3 pdf adobe air


【解决方案1】:

解决方案:

此 sn-p 适用于 Windows 和 Apple OSX:

var _myfilename = "John_Doe-tax_return_2011.pdf"; // = my filename

//run:

 //grab the original file by name (_myfilename) from your appDir:
 var realFile:File = File.applicationDirectory.resolvePath(_myfilename);#

 //get user's home directory:
 var destination:File = File.documentsDirectory;

 //copy the original file temponary to user's home directory:
 destination = destination.resolvePath(_myfilename);
 realFile.copyTo(destination,true);

 //open the temponary copy from user's home directory (acrobat or whatever):
 destination.openWithDefaultApplication();

//end;

不要忘记再次从用户的主目录中删除该文件(根据您公司的政策)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-27
    • 2013-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多