1.0.8 • Published 10 months ago

@logismiko/html-pdf v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months 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

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.0

10 months ago