Self-hosted · REST · Puppeteer-powered

Convert web pages & Markdown
to PDF with one request

PDFPi is a lightweight API that renders any public URL or Markdown document inside a headless Chromium browser and returns a pixel-perfect PDF — no browser plugins required.

▶ Web → PDF Playground 📄 Markdown → PDF 📄 API Reference

Everything you need

A focused set of features built for automation, browser extensions, and server-side document generation.

📄

Web → PDF

Pass any public URL as a query parameter and receive a link to a high-fidelity PDF rendered by Chromium — including backgrounds, fonts, and layout.

📝

Markdown → PDF

POST raw Markdown and receive a beautifully styled PDF. The server converts, sanitizes, and renders the document — perfect for reports, READMEs, and docs.

Rich Print Options

Control paper size (A3–Legal), orientation, scale, margins, and whether to include CSS backgrounds or print headers & footers.

🛠

Easy Self-Hosting

Single Node.js process on port 7301. Run bare-metal, inside Docker, or behind an Nginx reverse proxy in minutes.


Live Demo

Enter a public URL below, choose your options, and hit Generate PDF to see the API in action.

GET /pdf/generate

API Endpoints

All routes are served on the same port (default 7301).

GET
/pdf/generate
Render a URL to PDF via headless Chromium and return the download path.
Live
POST
/markdown/generate
Convert raw Markdown to a styled PDF via headless Chromium. Accepts a JSON body.
Live
GET
/downloads/:filename
Serve a previously generated PDF as a static file.
Live

Quick Start

Up and running in under five minutes.

Install dependencies
yarn install
Download Chromium (first run only)
npx puppeteer browsers install chrome
Start the dev server
yarn dev # → http://localhost:7301
Generate your first PDF
Open the URL below in your browser or run it with curl:
GET http://localhost:7301/pdf/generate?url=https://example.com&id=demo-001

Docker

# Build the image docker build -t pdfpi . # Run on port 7301 docker run -p 7301:7301 pdfpi

Parameter Reference

Parameters for GET /pdf/generate.

Parameter Type Default Description
url required string Full URL of the page to convert.
id required string Unique session identifier for this request.
size optional A3 | A4 | A5 | Legal | Letter A4 Paper format.
landscape optional "true" | "false" false Landscape orientation.
scale optional number (70–150) 100 Rendering scale as a percentage.
printBackground optional "true" | "false" true Include CSS backgrounds in the output.
printHeaderFooter optional "true" | "false" false Show date/URL header and page-number footer.
margin optional number ≥ 0 0 Global margin (px) applied to all four sides.
marginTop optional number ≥ 0 margin Top margin override (px).
marginRight optional number ≥ 0 margin Right margin override (px).
marginBottom optional number ≥ 0 margin Bottom margin override (px).
marginLeft optional number ≥ 0 margin Left margin override (px).

Body fields for POST /markdown/generate (JSON).

Field Type Default Description
markdown required string Raw Markdown text to convert. Max 500 KB.
title optional string "Document" PDF filename (without extension) and document title.
size optional A3 | A4 | A5 | Legal | Letter A4 Paper format.
landscape optional boolean false Landscape orientation.
scale optional number (70–150) 100 Rendering scale as a percentage.
printBackground optional boolean true Include CSS backgrounds.
printHeaderFooter optional boolean false Show title header and page-number footer.
margin optional number ≥ 0 0 Global margin (px) for all sides.
marginTop / Right / Bottom / Left optional number ≥ 0 margin Per-side margin overrides (px).
save optional boolean false Upload the generated PDF to Google Drive.