我试图保存此示例的pdf文件:
http://gonehybrid.com/how-to-create-and-display-a-pdf-file-in-your-ionic-app/
到我的localData。我发现我需要文件插件,但我不知道如何将blob文件保存到我的系统。我试过这两个:
$cordovaFile.createFile(cordova.file.dataDirectory, $scope.pdfUrl, true)
.then(function (success) {
// success
}, function (error) {
// error
});
或
cal = find(:xpath, "//div[@class='dhx_cal_container']")
page.driver.browser.mouse.move_to(cal.native, 240, 250)
page.driver.browser.mouse.down
page.driver.browser.mouse.move_by(0, 150)
page.driver.browser.mouse.up
但我无法存储它。我怎么能这样做?
答案 0 :(得分:7)
我的解决方案:
var pathFile = "";
var fileName = "report.pdf";
var contentFile = blob;
if (ionic.Platform.isIOS()) {
pathFile = cordova.file.documentsDirectory
} else {
pathFile = cordova.file.externalDataDirectory
}
$cordovaFile.writeFile(pathFile, fileName, contentFile, true)
.then(function(success) {
//success
}, function(error) {
alert("error in the report creation")
});