1.3.0 • Published 5 years ago
export-web-to-pdf v1.3.0
export-web-to-pdf
Node.js lib to export any web page to PDF.
Installation
npm install export-web-to-pdfor if you rather use yarn
yarn add export-web-to-pdfUsage
const exportWebToPdf = require("export-web-to-pdf");
exportWebToPdf("http://www.example.com", exportOptions)
.then(data => {
// .. do something with PDF data, like saving to a file or upload to S3 ..
});See the sample/ folder for a running example.
API
let response = exportWebToPdf(url, options);Parameters
url (string) URL you want converted to PDF
options (object) An options object containing custom settings. The possible options are:
loadingTimeout: Maximum amount of time to wait for navigation to finish. Defaults to30000.auth.usernameauth.password: Adds username and password to the request.ignoreHTTPSErrors: Whether to ignore HTTPS errors during navigation. Defaults tofalse.showBrowserConsole: Whether to log the browser's console messages. Defaults tofalse.waitForSelectors: Array of CSS selectors. If defined, it will wait until all CSS selector are found in the page before continuing.screenshotPath: If defined saves a screenshot of the navigated URL. This only works whenwaitForSelectorsare not found on the page, as a debugging tool.pdfSettings: Options object with PDF settings. Check Puppeteers's documentation for details.
Return value
A Promise that resolves to a Buffer with the PDF content.