2012-12-10 24 views

回答

1

1-确保您的web服务返回PDF文件。

2-使用文件系统来管理文件

var xhr = Titanium.Network.createHTTPClient({ 
    onload : function() { 

     var f = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'file.pdf'); 
     f.write(this.responseData); 

     tmpFile = Ti.Filesystem.createTempFile(); 
     var newPath = tmpFile.nativePath + "." + f.extension(); 
     Ti.API.info("newPath: " + newPath); 
     tmpFile = Ti.Filesystem.getFile(newPath); 
     tmpFile.write(f.read()); 

    }, 
    timeout : 10000 
}); 
xhr.open('GET', 'your webservice'); 
xhr.send(); 

现在您使用PDF阅读器,并从externalStorageDirectory 我在Android测试打开PDF,它的作品!

+0

它可以在iOS上使用吗? – JRC

相关问题