PDF Generator
Simple API service for generating professional PDF documents from HTML content. Designed for invoices, contracts, reports and internal documentation. Supports printable page margins, custom page width, and receipt-style PDFs with automatic height.
https://pdf.bizkithub.com/generatorSend the HTML as request body (text/html or plain text). Query parameters control layout, margins, paper size and receipt mode.
Query Parameters
| Parameter | Type | Behavior |
|---|---|---|
content | string | HTML content to render. Usually sent as POST body. For GET requests it can be provided as ?content=. |
format | string | Standard paper format (e.g. A4, Letter). Used when width is not set. Default is A4. |
width | string | Custom page width (CSS length, e.g. 80mm, 210mm, 800px). When set, it overrides format and makes the page size explicit. |
height | string | Custom page height (CSS length). Used only in fixed-size mode. If width is set and fitHeight is not enabled, the default height behaves like A4 height (297mm). |
autoHeight | boolean | Switches from zero margins to print-safe margins that apply consistently across pages. This improves page breaks and prevents content from being cut off at page edges. |
margin | string | Overrides margin size when autoHeight=true. Accepts CSS shorthand (1-4 values), e.g. 12mm 10mm or 2mm. |
fitHeight | boolean | Receipt mode: generates a single-page PDF whose height is derived from rendered content. Ideal for receipts and long single documents where pagination is not desired. Works best together with width (e.g. 80mm). |
uuid | string | Optional identifier. If provided, it is stored in PDF metadata keywords. |
author | string | Optional author label included in PDF metadata (Author/Creator/Producer). |
Defaults: without autoHeight margins are zero. With autoHeight=true the service applies sensible print margins (A4-style for standard pages, smaller margins for narrow receipt widths). Use margin to override.
How Combinations Work
Paper Sizing Priority
If width is provided, it becomes the primary sizing input and overrides format. If height is also provided, the page size is fully explicit. If only width is provided (and fitHeight is not enabled), a standard page height is used as default.
Margins via autoHeight
By default, the service renders with zero margins. When autoHeight=true is enabled, margins are applied consistently across pages, improving print correctness and page breaks. Use margin to override the default margin size.
Receipt Mode (fitHeight)
When fitHeight=true is enabled, the PDF is generated as a single page whose height is derived from the rendered content. This avoids pagination and is best used with a fixed width (e.g. 80mm) and small margins.
Examples
Default (zero margins)
Renders content edge-to-edge. Best for full-bleed designs or when you fully control your own internal padding in HTML.
POST https://pdf.bizkithub.com/generatorA4 with print-safe margins
Enables consistent per-page margins so page breaks don't clip content. Recommended for multi-page documents.
POST https://pdf.bizkithub.com/generator?autoHeight=trueCustom narrow page width with margins
Useful for narrow documents that can still paginate (e.g. very long receipts or logs).
POST https://pdf.bizkithub.com/generator?autoHeight=true&width=80mmReceipt mode: single page, auto height
Ideal for thermal receipts: no pagination, height is computed from rendered content.
POST https://pdf.bizkithub.com/generator?autoHeight=true&fitHeight=true&width=80mm&margin=2mmCustom margin size
Override margins when autoHeight is enabled. Accepts CSS shorthand (1-4 values).
POST https://pdf.bizkithub.com/generator?autoHeight=true&width=80mm&margin=2mmExplicit page size using width + height
For fully controlled page sizing (e.g. labels, tickets).
POST https://pdf.bizkithub.com/generator?autoHeight=true&width=100mm&height=150mm&margin=4mmIn multi-page mode, keep your HTML layout "print friendly" (avoid fixed-height containers for long content). For receipts in fitHeight mode, keep content width responsive and let text wrap naturally.
JavaScript Integration
async function generatePDF(htmlContent, options = {}) {
const params = new URLSearchParams();
if (options.autoHeight) params.set('autoHeight', 'true');
if (options.width) params.set('width', options.width);
if (options.fitHeight) params.set('fitHeight', 'true');
if (options.margin) params.set('margin', options.margin);
const url = `https://pdf.bizkithub.com/generator?${params}`;
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'text/html' },
body: htmlContent
});
if (!response.ok) throw new Error('PDF generation failed');
return await response.blob();
}
// Invoice example (multi-page with margins)
const invoicePdf = await generatePDF(invoiceHtml, { autoHeight: true });
// Receipt example (single page, 80mm width)
const receiptPdf = await generatePDF(receiptHtml, {
autoHeight: true,
fitHeight: true,
width: '80mm',
margin: '2mm'
});