Skip to content

Latest commit

 

History

History
130 lines (78 loc) · 2.4 KB

README.md

File metadata and controls

130 lines (78 loc) · 2.4 KB

krldf

Saves a webpage as PDF using Chrome's Puppeteer

Install

npm install pierrecholhot/krldf

Usage

const krldf = require('krldf')

krldf({ url: 'https://www.google.com/' })

with async/await callback

const krldf = require('krldf')

async function capture(opts) {
  const path = await krldf(opts)
  console.log(path ? 'success' : 'failure')
}

capture({ url: 'https://www.google.com/' })

CLI

./node_modules/krldf/cli.js --url="https://www.google.com/"

or via npx

npx krldf --url="https://www.google.com/"

or via global install

npm install -g pierrecholhot/krldf
krldf --url="https://www.google.com/"

Options

url

Type: string

Default: about:blank

⚙️ URL of the page to be converted. The url should include scheme, e.g. https://

delay

Type: number

Default: 3000

⚙️ Number of ms to wait before capture. Useful when waiting for authentication services

width

Type: number

Default: 2560

⚙️ Width of the capture viewport

height

Type: number

Default: 1440

⚙️ Height of the capture viewport

path

Type: string

Default: result.pdf

⚙️ The file path to save the PDF to. If path is a relative path, then it is resolved relative to current working directory.

landscape

Type: boolean

Default: false

⚙️ Enable paper landscape orientation

headerTemplate

Type: string

Default:

⚙️ HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:

  • date formatted print date
  • title document title
  • url document location
  • pageNumber current page number
  • totalPages total pages in the document

footerTemplate

Type: string

Default:

⚙️ HTML template for the print footer. Should be valid HTML markup with following classes used to inject printing values into them:

  • date formatted print date
  • title document title
  • url document location
  • pageNumber current page number
  • totalPages total pages in the document