Ionic pdf generator


#1

i can download a pdf in a browser but its not working in mobile app so can you suggest any solution?


#2

See:


#3

thanks but here am using ionic 2 so could u help this?


#4

Ionic 2 uses angular 2.

So angular 2 examples are what you need


#5

yeah i knows but its working in browser and not in my app while am using cordova platform


#6

follow this link:

  1. https://www.npmjs.com/package/cordova-pdf-generator

  2. https://github.com/cesarvr/ionic2-basic-example

generatePdf(){
const before = Date.now();

document.addEventListener('deviceready', () => {
  console.log('DEVICE READY FIRED AFTER', (Date.now() - before), 'ms');
  var file = 'file:///android_asset/www/assets/lolc.html';
// var file = 'https://www.google.com/';

  cordova.plugins.pdf.fromURL(file,{
    documentSize: "A4",
    landscape: "portrait",
    type: "share"
  }),
    (sucess) => console.log('sucess: ', sucess),
    (error) => console.log('error:', error);
});

}