Socket
Socket
Sign inDemoInstall

@cityssm/pdf-puppeteer

Package Overview
Dependencies
217
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @cityssm/pdf-puppeteer

A simple NPM package to convert html to pdf for Node applications by using Puppeteer


Version published
Weekly downloads
89
increased by122.5%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

PDF-Puppeteer

npm (scoped) Code Climate maintainability codecov DeepSource

A simple npm package to convert HTML to PDF for Node.js applications by using Puppeteer.

Based on the work in westmonroe/pdf-puppeteer. Forked to manage dependencies, switch to ESM, and eliminate the callback function.

Installation

npm install @cityssm/pdf-puppeteer

Usage

import { convertHTMLToPDF } from "@cityssm/pdf-puppeteer";

/**
 * Usage
 * @param html - This is the HTML to be converted to a PDF.
 * @param [pdfOptions] - Optional parameter to pass in Puppeteer PDF options.
 * @param [pdfPuppeteerOptions] - Optional parameter to pass in PDF Puppeteer options.
 */
const pdfBuffer = await convertHTMLToPDF(html, pdfOptions, pdfPuppeteerOptions);

// Do something with the PDF, like send it as the response.
res.setHeader("Content-Type", "application/pdf");
res.send(pdfBuffer);

The convertHTMLToPDF() function takes the three parameters detailed above.

For more information on the available Puppeteer options for PDFs, take a look at Puppeteer's Page PDF Options.

PDF Puppeteer Options

OptionDescriptionDefault Value
cacheBrowserWhether or not the Puppeter browser instance should be saved between PDFs.false
remoteContentWhether or not the HTML contains remote content.true
htmlIsUrlWhether or not the html parameter is actually a URL that should be navigated to.false

Keywords

FAQs

Last updated on 30 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc