Categories

HTML to PDF Renderer

Render a limited HTML subset into a PDF with a deterministic layout

Render HTML into PDF using a deterministic subset renderer.

Supported tags:

  • p, h1-h6, ul/ol, table, img, code

Modes:

  • Subset renderer (PDFKit)
  • Browser renderer (Puppeteer) for full HTML/CSS

Example Results

1 examples

HTML Renderer

Browser render mode sample

html-to-pdf-renderer-example1.pdf View File
View input parameters
{ "htmlContent": "<h1 style='color:#1f2937'>Browser Mode</h1><p>Sample layout.</p>", "cssContent": "body { font-family: Arial, sans-serif; }", "renderMode": "browser", "printBackground": true, "waitUntil": "load" }

Click to upload file or drag and drop file here

Maximum file size: 10MB Supported formats: text/html, application/xhtml+xml, text/plain

Key Facts

Category
Document Tools
Input Types
textarea, file, text, select, checkbox, number
Output Type
file
Sample Coverage
4
API Ready
Yes

Overview

The HTML to PDF Renderer is a versatile utility designed to convert web content into professional PDF documents using either a deterministic subset renderer for simple layouts or a full browser-based engine for complex styling.

When to Use

  • Converting simple HTML snippets or documents into standardized PDF files.
  • Generating high-fidelity PDFs from complex web pages that require full CSS and JavaScript support.
  • Creating printable reports or documentation from raw HTML or existing URLs.

How It Works

  • Input your HTML content via text, file upload, or by providing a direct URL.
  • Select your preferred render mode: 'Subset' for lightweight PDFKit processing or 'Browser' for full Puppeteer rendering.
  • Adjust page settings such as size, orientation, margins, and scaling to match your document requirements.
  • Execute the conversion to generate and download your finalized PDF file.

Use Cases

Generating invoices or receipts from HTML templates.
Archiving web articles or documentation pages as static PDFs.
Creating printable versions of internal reports or data dashboards.

Examples

1. Browser-Based Report Generation

Web Developer
Background
A developer needs to convert a dynamic internal dashboard into a PDF report for management.
Problem
The dashboard uses complex CSS and external assets that simple renderers cannot interpret correctly.
How to Use
Select 'Browser (Puppeteer)' mode, input the dashboard URL, and set the media type to 'print' for optimal layout.
Example Config
renderMode: browser, mediaType: print, waitUntil: networkidle0
Outcome
A perfectly formatted PDF that mirrors the visual layout of the live web dashboard.

2. Simple Document Conversion

Content Writer
Background
A writer has a clean HTML file containing a technical article and needs to share it as a PDF.
Problem
The file is simple and does not require heavy browser rendering, but needs consistent margins and font sizing.
How to Use
Upload the HTML file, choose 'Subset (PDFKit)' mode, and configure the margins and font size.
Example Config
renderMode: subset, pageSize: A4, marginTop: 20, marginBottom: 20, fontSize: 12
Outcome
A lightweight, clean PDF document generated quickly with consistent document styling.

Try with Samples

xml, html, pdf

Related Hubs

FAQ

What is the difference between Subset and Browser modes?

Subset mode uses PDFKit for fast, deterministic rendering of basic HTML tags, while Browser mode uses Puppeteer to render full HTML/CSS as a browser would.

Which HTML tags are supported in Subset mode?

Subset mode supports standard structural tags including p, h1-h6, ul/ol, table, img, and code.

Can I apply custom styles to my PDF?

Yes, you can provide custom CSS content when using the Browser render mode to fully control the visual output.

How do I handle relative assets like images?

You can specify a Base URL in the settings to ensure the renderer correctly resolves relative paths for images and other assets.

Is it possible to change the page orientation?

Yes, you can toggle the 'Landscape' checkbox in the settings to switch between portrait and landscape orientations.

API Documentation

Request Endpoint

POST /en/api/tools/html-to-pdf-renderer

Request Parameters

Parameter Name Type Required Description
htmlContent textarea No -
htmlFile file (Upload required) No -
url text No -
baseUrl text No -
cssContent textarea No -
renderMode select No -
pageSize select No -
landscape checkbox No -
printBackground checkbox No -
scale number No -
marginTop number No -
marginBottom number No -
marginLeft number No -
marginRight number No -
fontSize number No -
lineHeight number No -
mediaType select No -
waitUntil select No -
waitTime number No -

File type parameters need to be uploaded first via POST /upload/html-to-pdf-renderer to get filePath, then pass filePath to the corresponding file field.

Response Format

{
  "filePath": "/public/processing/randomid.ext",
  "fileName": "output.ext",
  "contentType": "application/octet-stream",
  "size": 1024,
  "metadata": {
    "key": "value"
  },
  "error": "Error message (optional)",
  "message": "Notification message (optional)"
}
File: File

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-html-to-pdf-renderer": {
      "name": "html-to-pdf-renderer",
      "description": "Render a limited HTML subset into a PDF with a deterministic layout",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=html-to-pdf-renderer",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

Supports URL file links or Base64 encoding for file parameters.

If you encounter any issues, please contact us at [email protected]