PDF API – Convert Websites & HTML to PDF via Web Service

Integrate the web-to-PDF conversion of web2pdf.eu directly into your application. A simple HTTP interface returns pixel-perfect PDFs – without watermarks, GDPR-compliant.

Endpoint

Send a POST request with the target URL as JSON. The response is the PDF directly.

MethodPOST
URLhttps://web2pdf.eu/api/generate-pdf
HeaderContent-Type: application/json
Body{ "url": "https://example.com" }
Responseapplication/pdf (binary data)

Example: curl

curl -X POST https://web2pdf.eu/api/generate-pdf \
     -H "Content-Type: application/json" \
     -d '{"url": "https://www.google.com"}' \
     --output google.pdf

Example: JavaScript / Node.js

// Node.js / Browser (fetch)
const res = await fetch("https://web2pdf.eu/api/generate-pdf", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://example.com" })
});

const buffer = Buffer.from(await res.arrayBuffer());
await require("fs/promises").writeFile("example.pdf", buffer);

Example: PHP

<?php
$ch = curl_init("https://web2pdf.eu/api/generate-pdf");
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS     => json_encode(["url" => "https://example.com"]),
    CURLOPT_RETURNTRANSFER => true,
]);
$pdf = curl_exec($ch);
curl_close($ch);
file_put_contents("example.pdf", $pdf);

Example: Python

# Python (requests)
import requests

res = requests.post(
    "https://web2pdf.eu/api/generate-pdf",
    json={"url": "https://example.com"},
)
with open("example.pdf", "wb") as f:
    f.write(res.content)

HTML instead of URL: HTML-to-PDF API

Already have HTML and CSS and want to create a PDF from it? Send your markup to the endpoint POST /api/html-to-pdf with the body { "html": "…", "css": "…" }. Try it in the browser with the HTML-to-PDF converter.

Typical use cases

  • Automatically generate invoices, quotes and reports as PDF.
  • Archive websites and articles server-side.
  • Integrate PDF export into SaaS applications, dashboards and CMS.
  • Create screenshots of entire pages as a print-ready document.

Frequently Asked Questions

How does the web-to-PDF API work?

Send a POST request with { "url": "…" } to /api/generate-pdf. The response is the finished PDF (application/pdf) – without watermark.

Can I convert HTML to PDF instead of a URL?

Yes. Use the endpoint /api/html-to-pdf and send { "html": "…", "css": "…" }.

What does the PDF API cost?

Getting started is free. The API runs GDPR-compliant on servers in the EU.

Which programming languages are supported?

Any language with HTTP support – curl, JavaScript/Node.js, PHP, Python, Java, Go, C# and more.