1.0.8 • Published 1 year ago

@logismiko/html-pdf v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@logismiko/html-pdf

Convert HTML content or web pages to PDF using Node.js and Puppeteer.

Installation

npm install @logismiko/html-pdf

Usage

import { generatePdf } from '@logismiko/html-pdf';

// Generate single PDF
const file = { content: "Welcome" };
// or
const file = { url: "https://example.com" };

const options = { format: 'A4' };

// Promise
generatePdf(file, options)
  .then(pdfBuffer => {
    console.log("PDF Buffer:-", pdfBuffer);
  });

// Callback
generatePdf(file, options, (err, pdfBuffer) => {
    if (err) {
      console.log(err);
      return;
    }
    console.log("PDF Buffer:-", pdfBuffer);
  });

Options

The options parameter accepts all Puppeteer PDF options.

Common options include:

  • format: 'A4', 'Letter', etc.
  • path: File path to save the PDF to
  • width: Page width
  • height: Page height
  • printBackground: Include background graphics
  • margin: Page margins

License

ISC

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.0

1 year ago