cesarvr / pdf-generator

Cordova plugin to generate pdf in the client-side
MIT License
107 stars 61 forks source link

This plugin has become obsolete for the ionc 3? #76

Open ChristopherBDev opened 6 years ago

ChristopherBDev commented 6 years ago

I am trying to use this plugin with cordova and ionic 3. I already installed it through the following commands:

$ cordova plugin add cordova-pdf-generator;

$ npm install cordova-pdf-generator;
$ cordova plugins add node_modules/cordova-pdf-generator;

I tried to use the following syntax, according to the documentation:

declare var cordova: any;

And after that, I try to use the fromURL() function:

`cordova.plugins.pdf.fromURL('My_url', options)
  .then((stats) => console.log('status', stats))
  .catch((err) => console.log(err));`
(<any>cordova).pdf.fromURL('My_url', options)
  .then((stats) => console.log('status', stats))
  .catch((err) => console.log(err));

However, in execution the method is not recognized. Being the cord and ( cord) indefinite. Do you know a solution for the plugin method to be correctly referenced?

cesarvr commented 6 years ago

I create this example using ionic2 hope is useful for you:

home.ts.

On that example I'm using there an older version of the API, but it should work with the new version as well: cordova.pdf.fromURL

Ionic2 Project

ChristopherBDev commented 6 years ago

I had already tried this same solution that you portray in the example.

However in the command: cordova.pdf.fromURL,cordova is null.

Is there any restriction of this feature to work only when tested on mobile devices? Does it work on an android emulator?

h4rm commented 6 years ago

For me it is window.cordova.... Maybe that helps.