🖥 -> 🌲 -> 📄 -> 🖨
Exposes a web server with a single endpoint to take in a URL and create a PDF out of that. It's using Playwright in the background for this.
- Node 24+ (see
.node-version) - npm
git checkout https://github.com/rmehner/bits-to-dead-treescd bits-to-dead-treesnpm installnpm startto start the server. It'll listen to port 8000 on localhost by default.
- After updating the
playwrightdependency, you should runnpm run update-schemasto make sure that the server knows about new PDF options - Use
npm run start:devto start everything in dev mode with build watch and friends
The server exposes the /pdf endpoint that listens to a POST request and expects a JSON body:
{
"url": "https://your-target-url.com/site/you/want/a/pdf/of",
"pdfOptions": {},
"gotoOptions": {},
"browserContextOptions": {}
}pdfOptionsare the options for thepdfcall in Playwright: https://playwright.dev/docs/api/class-page#page-pdf.gotoOptionsare the options for thegotomethod in Playwright: https://playwright.dev/docs/api/class-page#page-goto- if you don't pass anything, we default to a timeout of 60000 and wait for
networkidle
- if you don't pass anything, we default to a timeout of 60000 and wait for
browserContextOptionsare the options for the browser context in Playwright: https://playwright.dev/docs/api/class-browser#browser-new-context- if you don't pass anything, we default to set
ignoreHTTPSErrorstotrue
- if you don't pass anything, we default to set
The response is the PDF file.
Versions are automatically build as Docker images and are available on GitHub's package registry
If you want to use it internally with docker-compose, this should give you a good idea to start:
services:
pdf:
image: ghcr.io/rmehner/bits-to-dead-trees:v2.29.0
ports:
- 8000:8000