-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
where does pdf get saved on the device when we call download #1030
Comments
@prabodh25 - You need to implement cordova file plugin and file opener plugin to make this work on device with Ionic 2/3/x |
@sunilkconsultant - Thanks for reply. Cordova file plugin expects path for the file to be opened. My question is how to get the dowloaded file path. |
I checked the code for download method and there is callback function we can pass as argument to the method but it does not return anything. It would be good idea to return complete file path to callback function. |
Ok. After banging my head on wall for 3 days I finally found the solution and sharing here so that other people who are facing this issue can get help. I am creating pdf and saving it using cordova file plugin. After successful save I am opening it in default application using cordova file opener plugin. Below is my code. pdfMake.createPdf(YOUR_DEFINITION_HERE).getBlob(buffer => {
this.file.resolveDirectoryUrl(this.file.externalRootDirectory)
.then(dirEntry => {
this.file.getFile(dirEntry, 'test1.pdf', { create: true })
.then(fileEntry => {
fileEntry.createWriter(writer => {
writer.onwrite = () => {
this.fileOpener.open(fileEntry.toURL(), 'application/pdf')
.then(res => { })
.catch(err => {
const alert = this.alertCtrl.create({ message: err.message, buttons: ['Ok'] });
alert.present();
});
}
writer.write(buffer);
})
})
.catch(err => {
const alert = this.alertCtrl.create({ message: err, buttons: ['Ok'] });
alert.present();
});
})
.catch(err => {
const alert = this.alertCtrl.create({ message: err, buttons: ['Ok'] });
alert.present();
});
}); |
hai @prabodh25 can you help me ? i get this error : Cannot read property 'resolveDirectoryUrl' of undefined thank you |
@rendy14s change https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/ |
when i print or open PDF( pdfMake.createPdf(context).print(); ), i get this error ,: |
hi, @prabodh25 but for large data the pdf pages will split into two and they dont return any content . its just returns empty pdf pages Can you please help me to sort out this @liborm85. my code: vm.exportPDF = function () { |
When i call pdfMaker.createPdf(documentDefinition) i get error: is not assignable to parameter of type 'TDocumentDefinitions'. Types of property 'content' are incompatible. |
Hi,
First of all let me say that its a great library for creating pdf. Thanks a lot!
I am creating pdf in my Ionic 3 - angular 4 app and want to open it in default application after creating. Could you please tell me where does file get saved on the device and how to get its path. I am creating file like this.
pdfMake.createPdf(dd).download('mypdf.pdf')
The text was updated successfully, but these errors were encountered: