HTML to PDF Developer SDK

Convert HTML to PDF with speed & precision.

Html2Pdf is a developer-first SDK that renders your HTML templates into crisp, standard PDF documents in headless Chromium, in a single request, with built-in fonts for 21 Indian languages.

100%
CSS & Layout Precision
1 call
HTML In, PDF Out
Zero
Infrastructure Friction
import { Html2PdfClient, PaperFormat, PdfOrientation } from '@akcraft/html2pdf-sdk';

// Initialize client with your API key
const apiKey = process.env.HTML2PDF_API_KEY;
const client = new Html2PdfClient(apiKey);

// Renders the PDF and stores it before the call returns
const job = await client.sendHtmlRequest({
  apikey: apiKey,
  userId: '3f2b8c1e-4d5a-4b6c-8d7e-9f0a1b2c3d4e', // Account ID from Settings
  content: '<h1>Invoice #1042</h1><p>Amount: $250.00</p>',
  options: { format: PaperFormat.A4, orientation: PdfOrientation.PORTRAIT }
});

// Fetch a fresh, time-limited download link
const { pdfUrl } = await client.getPdfUrl(job.fileName);

Preview Sandbox

Preview how your HTML becomes a PDF

Edit the HTML in the input editor and preview the rendered output. This sandbox runs in your browser without calling the API; open the sample PDFs to see real output from the rendering engine.

Input HTML Source
Preview — no API call
Your HTML stays in this browser
PDF Preview
Preview
📄

Click "Preview PDF" to see your HTML laid out as a page.

This preview doesn't call the API. The sample PDFs were rendered with the same Chromium engine and fonts the API uses. Get an API key to convert your own HTML.

SDK Capabilities

Built specifically for modern developer workflows

Html2Pdf simplifies PDF document generation into a clean, predictable API call.

⚡

One-Call Rendering

Send HTML and get back a finished PDF in the same request. When the response arrives, the document is already rendered and stored, with no job queue to poll.

🎨

Full HTML & CSS Support

Renders standard HTML, inline CSS, custom web fonts, tables and images in headless Chromium. Choose paper formats from A0 to Tabloid, portrait or landscape. Built-in fonts cover 21 Indian languages across 12 scripts.

🛡️

Type-Safe Client SDK

TypeScript-native SDK with clear type definitions (Html2PdfClient, SendHTMLRequest, Html2PdfStatus, ErrorResponse).

🔗

Secure Download Links

PDFs live in private storage. Call getPdfUrl with the file name to get a fresh presigned link, valid for 1 hour, whenever you need to download or share a document — and delete documents you no longer need.

🩺

Uptime & Health Monitoring

Built-in service health check primitives (getHealthStatus) for robust microservice integration and monitoring.

🚀

Zero Heavy Dependencies

Lightweight client footprint that integrates smoothly into Node.js backend services, serverless functions, or web apps.

🗑️

Full PDF Lifecycle Control

Generated PDFs don't pile up. Delete any document instantly from your dashboard, or let automatic cleanup remove files older than the 1-hour retention window — storage stays tidy with zero effort.

Indian Languages

Print in 21 Indian languages

The API bundles fonts for 12 scripts, so text in these languages prints correctly without you shipping any fonts. Just send your HTML.

Devanagari

नमस्ते

Hindi, Marathi, Sanskrit, Nepali, Konkani, Maithili, Bodo, Dogri

Bengali

নমস্কার

Bengali, Assamese, Manipuri

Gurmukhi

ਸਤ ਸ੍ਰੀ ਅਕਾਲ

Punjabi

Gujarati

નમસ્તે

Gujarati

Odia

ନମସ୍କାର

Odia

Tamil

வணக்கம்

Tamil

Telugu

నమస్కారం

Telugu

Kannada

ನಮಸ್ಕಾರ

Kannada

Malayalam

നമസ്കാരം

Malayalam

Meetei Mayek

ꯈꯨꯔꯨꯝꯖꯔꯤ

Manipuri

Ol Chiki

ᱡᱚᱦᱟᱨ

Santali

Nastaliq

خوش آمدید

Urdu, Kashmiri

SDK Architecture

Simple Data Model & Job Statuses

Html2Pdf's API design ensures predictable response schemas for every document conversion request. Each conversion finishes within its request and returns a job status your application can record.

Job Status Enum (Html2PdfStatus)

PENDINGReserved for a future job queue.
PROCESSINGReserved; renders finish within the request.
COMPLETEDPDF rendered and ready for download.
FAILEDError occurred during generation.

Html2PdfClient Methods

sendHtmlRequest(payload)POST

Calls POST /api/send-html with apikey, userId, HTML content and optional PDF settings. Renders and stores the PDF within the request, then returns jobId, fileName and status.

getPdfUrl(fileName)GET

Calls /pdfs/:fileName using the client's API key — passed to the Html2PdfClient constructor or persisted from sendHtmlRequest — and returns a fresh presigned download URL, valid for one hour.

getHealthStatus()GET

Pings /health endpoint to verify service operational health.