Git Product home page Git Product logo

export-web-to-pdf's Introduction

export-web-to-pdf

Build Status npm npm Coverage Status

Node.js lib to export any web page to PDF.

Installation

npm install export-web-to-pdf

or if you rather use yarn

yarn add export-web-to-pdf

Usage

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 to 30000.
  • auth.username
  • auth.password: Adds username and password to the request.
  • ignoreHTTPSErrors: Whether to ignore HTTPS errors during navigation. Defaults to false.
  • showBrowserConsole: Whether to log the browser's console messages. Defaults to false.
  • 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 when waitForSelectors are 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.