Generate pdf file with a webview and html.
All you need to do is rendering your html with a webview and pass the webview to the plugin.
For iOS, plugin returns the path of the generated PDF.
For Android, it brings up the printer screen where you can save as PDF (Please note the printer screen does not work in simulator, you will need a real device).
tns plugin add nativescript-generate-pdf
>> Check out the generated pdf<<
Check out the demo folder.
import { GeneratePdf } from 'nativescript-generate-pdf';
function onWebViewLoaded(args: LoadEventData) {
const webView = (<WebView>args.object).nativeView;
// For iOS, use the file path returned by createPdf.
new GeneratePdf().createPdf(webView, 'MyPdfFileName');
}
Apache License Version 2.0, January 2004