Simple API to Convert HTML into PDF format using a headless Chromium browser instance.
1.2K
Provides endpoints to convert raw HTML into a PDF document with configurable options.
The container starts up a headless Chrome browser instance (JavaScript and service workers disabled) and renders the provided HTML to export a PDF. Host this service privately and only pass trusted HTML content.
| Method | Path | Description |
|---|---|---|
GET | / | Returns the current API version |
POST | / | Converts HTML to a PDF file |
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
html | string | Yes | Raw HTML content to convert | |
fileName | string | No | "file" | Output filename (without extension) |
format | string | No | "Letter" | Page size: Letter, Legal, Tabloid, Ledger, A0–A6 |
printBackground | bool | No | true | Whether to include CSS backgrounds |
The container exposes port 5000 so you can bind that to a port number of your choice (8080 in the example below).
docker run -p 8080:5000 deventerprisesoftware/html2pdf
curl \
-d '{ "html": "<h1>HTML 2 PDF</h1><p>Sample text</p>", "format": "A4" }' \
-H "Content-Type: application/json" \
--output test_file.pdf \
-X POST "http://localhost:8080/"
using System.Net.Http;
using System.Text;
using System.Text.Json;
var request = JsonSerializer.Serialize(new
{
Html = "<h1>HTML 2 PDF</h1><p>Sample text</p>",
FileName = "test_file",
Format = "A4"
});
using var httpClient = new HttpClient();
using var requestContent = new StringContent(request, Encoding.UTF8, "application/json");
var response = await httpClient.PostAsync("http://localhost:8080/", requestContent);
response.EnsureSuccessStatusCode();
var pdfBytes = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("test_file.pdf", pdfBytes);
Content type
Image
Digest
sha256:8599aa2c9…
Size
602.9 MB
Last updated
4 months ago
docker pull deventerprisesoftware/html2pdf