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.
import { Html2PdfClient, PaperFormat, PdfOrientation } from '@akcraft/html2pdf-sdk';
// Requires HTML2PDF_BASE_URL in your environment
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.
Click "Preview PDF" to see your HTML laid out as a page.
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)
Html2PdfClient Methods
sendHtmlRequest(payload)POSTCalls 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)GETCalls /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()GETPings /health endpoint to verify service operational health.