Skip to content

A Node.js tool that leverages Puppeteer to seamlessly convert web pages into PDFs, with options for landscape orientation and selective content hiding.

License

Notifications You must be signed in to change notification settings

opendream/headless_pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

headless_pdf

A simple Node.js application that uses the Puppeteer library to generate PDFs from web pages in a headless manner.

Features

  • Convert any web page to a PDF.
  • Option to generate the PDF in landscape mode.
  • Hide specific elements from the PDF by adding the print-hide class to them.
  • Specify the filename for the downloaded PDF.

Prerequisites

  • Node.js
  • npm

Installation

  1. Clone the repository:

    git clone https://github.com/opendream/headless_pdf.git
  2. Navigate to the repository directory:

    cd headless_pdf
  3. Install the required dependencies:

    npm install

Usage

  1. Start the server:

    node index.js
  2. Access the service by navigating to:

    http://localhost:8080/headless-pdf?url=YOUR_WEBPAGE_URL
    

    Optional query parameters:

    • landscape: Set to true for landscape mode.
    • filename: Specify the name for the downloaded PDF file (without the .pdf extension).

    Example:

    http://localhost:8080/headless-pdf?url=https://www.example.com&landscape=true&filename=mydocument
    

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

A Node.js tool that leverages Puppeteer to seamlessly convert web pages into PDFs, with options for landscape orientation and selective content hiding.

Topics

Resources

License

Stars

Watchers

Forks