NodeJs Plugin to Generate PDF from HTML Template using Vuejs and Puppeteer

Pdf-Generator (html-pdf-generator on NPM)

A NodeJs plugin to generate PDF from HTML template using Puppeteer and Vue.js.

See postman collection for mare example,

If you need more functionality in your HTML template you can add the    mixins: Array   properties to the window object to extend Vue.js default functionality.

API

The options param is an object with the properties to config puppeteer and set the printing margin. See .env file in the demo app:

{
    interface Options {
        URL_BROWSER: string; // <DirToExecuteChromeOrFirefox>
        FILE_DIR: string; // <TemporalHTMLFileDir>
        PDF_DIR: string; // <TemporalPDFFileDir>
        TEMPLATE_DIR: string; // <TemplateDir> - templates
        PORT: number; // Port used in NodeJs service
        printingMarginTop?: string | number; // default 18mm
        printingMarginBottom?: string | number; // default 18mm
        printingMarginLeft?: string | number; // default 18mm
        printingMarginRight?: string | number; // default 18mm
        BROWSER_NAME?: string; // chrome|firefox - default chrome
        libs: Array<string> // List of js files used on the templates
    }
}
/**
 * Create a PDF Generator instance
 *
 * @param {*} options
 * @returns {*} pdfGenerator
 */
function pdfGenerator(options: Options); 

The function pdfGenerator returns:

{
    processTemplate: (data: {$templateName: string, $parameters: any, $extraParams: any}) => Promise<{fileName: string, buffer: Buffer}>;
    dispose: () => Promise<void>;
}
/**
 * Real all the params found in a HTML template with the Vue.js template syntax.
 *
 * @param string templateName
 * @returns Promise<{[key: string]: any}>
 */
function getTemplateParameters(templateName: string): Promise<{[key: string]: any}>;

Download Details:

Author: juanchinovas

Source Code: https://github.com/juanchinovas/pdf-generator

#vue #vuejs #nodejs #javascript

NodeJs Plugin to Generate PDF from HTML Template using Vuejs and Puppeteer
14.00 GEEK