Closed h2naashley closed 7 years ago
Hi @h2naashley , this happens because the content is being downloaded and is taking to much (maybe slow connection), are you fetching the template from an external server ?, you can try to put your content in the device itself and try again.
Thank u for your kind response, like your advice , I've tested two ways already
with URL to "http://google.com" , pdf.htmlToPDF({ url: "http://www.google.com", //url : this.url_new, documentSize: "A4", landscape: "portrait", type: "base64" }, this.success, this.failure);
without url as following pdf.htmlToPDF({ data: "
Give me the same result.
can you try this example just to see if it works with basic cordova? I will try to make a simple ionic 2 "hello world" to check if it I have found any problems. Cheers!.
Thanks. I've tried your example cordova app. It works perfectly. thanks. please kindly let me know after u test with ionic2, Thank u your kind help.
May I know Is there any update about ionic2 integration?
Hi @h2naashley , take a look at this example just make sure you are using version of the plugin 1.0.11, in that release I add implement support to call the module under the cordova.plugins namespace.
basic example:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
declare var cordova:any; //global;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
const before = Date.now();
document.addEventListener('deviceready', () => {
console.log('DEVICE READY FIRED AFTER', (Date.now() - before), 'ms');
//generate the pdf.
cordova.plugins.pdf.htmlToPDF({
data: "<html> <h1> Hello World </h1> </html>",
//url: "www.cloud.org/template.html"
},
(sucess) => console.log('sucess: ', sucess),
(error) => console.log('error:', error));
});
}
}
basic ionic 2 example. This example is very basic because I not very good Angular2, feel free to improve it and send a PR if you like :+1: . Cheers.
Thank you it works perfectly. Thanks u for your help and guidance.
Helo, I am currently trying to use this amazing library with ionic2. But i am very new to ionic2 and cordova platform. and now i encounter the following issue : "The app stops at the stage of showing "Preparing preview" step described in the following screencast."
What things i need to do else in order to overcome it? Thanks u , really appreciate help