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.

API Endpoint
POSThttps://pdf.bizkithub.com/generator

Send the HTML as request body (text/html or plain text). Query parameters control layout, margins, paper size and receipt mode.

Query Parameters

ParameterTypeBehavior
contentstringHTML content to render. Usually sent as POST body. For GET requests it can be provided as ?content=.
formatstringStandard paper format (e.g. A4, Letter). Used when width is not set. Default is A4.
widthstringCustom page width (CSS length, e.g. 80mm, 210mm, 800px). When set, it overrides format and makes the page size explicit.
heightstringCustom 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).
autoHeightbooleanSwitches 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.
marginstringOverrides margin size when autoHeight=true. Accepts CSS shorthand (1-4 values), e.g. 12mm 10mm or 2mm.
fitHeightbooleanReceipt 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).
uuidstringOptional identifier. If provided, it is stored in PDF metadata keywords.
authorstringOptional 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

1

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.

2

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.

3

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/generator

A4 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=true

Custom 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=80mm

Receipt 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=2mm

Custom 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=2mm

Explicit 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=4mm

In 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'
});