建议的解决方案是什么?使用Acrobat(或任何其他阅读器)打开嵌入式 pdf文档。我跟着一个类似的问题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!)
答案 0 :(得分:1)
此代码段适用于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;
不要忘记再次从用户的主目录中删除该文件(关于您的comapnie政策)。