Skip to content

About

Express and Puppeteer service for rendering web pages as A4 landscape PDFs.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

PDF Creator

An Express service that uses Puppeteer to render a web page as an A4 landscape PDF. The page URL comes from the request’s Referer header; an optional Cookie header is forwarded to the browser page.

Run locally

Install Node.js and npm, then run:

npm ci
node index.js

The service listens on port 5001, or the value of PORT. Puppeteer’s browser download and its operating-system dependencies are required.

Generate a PDF

With the service running, request a page you are authorized to render:

curl --fail --header "Referer: https://example.com" http://localhost:5001/pdf --output example.pdf

A successful response has content type application/pdf. Output uses A4 paper, landscape orientation, printed backgrounds, and a scale of 0.7.

Configuration

Variable Purpose
PORT Listening port; defaults to 5001.
NODE_ENV When set to production, uses Chrome at /usr/bin/google-chrome.

npm start runs the service with nodemon. A Dockerfile is included; its production browser path is selected only when NODE_ENV=production is set.

Current limitations

This is a small prototype. It does not authenticate requests or restrict destination URLs. Keep it local or behind trusted access controls, and do not send sensitive cookies to untrusted destinations. Browser cleanup on error is not guaranteed. The repository has no automated test suite; these instructions document the implementation and have not been runtime-validated.

About

Express and Puppeteer service for rendering web pages as A4 landscape PDFs.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages