A simple Node.js application that uses the Puppeteer library to generate PDFs from web pages in a headless manner.
- 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.
- Node.js
- npm
-
Clone the repository:
git clone https://github.com/opendream/headless_pdf.git
-
Navigate to the repository directory:
cd headless_pdf
-
Install the required dependencies:
npm install
-
Start the server:
node index.js
-
Access the service by navigating to:
http://localhost:8080/headless-pdf?url=YOUR_WEBPAGE_URL
Optional query parameters:
landscape
: Set totrue
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
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.