Saves a webpage as PDF using Chrome's Puppeteer.
npm install pierrecholhot/krldf
const krldf = require('krldf')
krldf({ url: 'https://www.google.com/' })
Example in examples/node-promises.js
Example in examples/node-async.js
Example in examples/cli.sh
./node_modules/krldf/cli.js --url="https://www.google.com/"
or via npm global install
krldf --url="https://www.google.com/"
or via npx
npx krldf --url="https://www.google.com/"
Type : string
Default : about:blank
Description : URL of the page to be converted.
The url should include scheme, e.g. https://
.
Type : string
Default : result.pdf
Description : The file path to save the PDF to.
If filePath
is a relative path, then it is resolved relative to current working directory.
Type : number
Default : 2000
Description : Number of ms
to wait after navigation succeeded.
Useful when waiting for authentication services.
Type : string
Default : networkidle0
Description : When to consider navigation succeeded. More on page.goTo({ waitUntil })
.
load
consider navigation to be finished when theload
event is fired.domcontentloaded
consider navigation to be finished when theDOMContentLoaded
event is fired.networkidle0
consider navigation to be finished when there are no more than 0 network connections for at least500
ms.networkidle2
consider navigation to be finished when there are no more than 2 network connections for at least500
ms.
Type : number
Default : 2560
Description : Width of the capture viewport.
Type : number
Default : 1440
Description : Height of the capture viewport.
Type : string
Default : A4
Options : Letter
, Legal
, Tabloid
, Ledger
, A0
, A1
, A2
, A3
, A4
, A5
, A6
Type : boolean
Default : false
Description : Enable paper landscape orientation.
Type : string
Default : (empty strings)
Description : HTML templates for the print header and print footer.
Should be valid HTML markup with following classes used to inject printing values into them :
date
formatted print datetitle
document titleurl
document locationpageNumber
current page numbertotalPages
total pages in the document
Type : array
Default : []
Description : Additional arguments to pass to the browser instance.
The list of Chromium flags can be found here.