# PDF & Document Generation API — Zylalabs Description
**Copy-paste the text below into Zylalabs' "Long Description" field:**
---
## Overview
The PDF & Document Generation API is a production-grade REST API that converts HTML, URLs, and structured data into pixel-perfect PDF documents. Built for developers who need to automate document workflows — invoices, receipts, reports, contracts, dashboards — without managing browser engines, Chromium servers, or rendering infrastructure.
Powered by ProdaDoc, this API handles the entire PDF pipeline: generation, merging, and metadata extraction, all through simple JSON-in, PDF-out endpoints.
## Key Features
**HTML to PDF Conversion**
Send any HTML string — with full CSS support including Flexbox, Grid, custom fonts, and print media queries — and receive a production-quality PDF in milliseconds. Perfect for converting email templates, dashboards, and custom documents into downloadable PDFs.
**URL to PDF Conversion**
Convert any publicly accessible webpage into a PDF document. The API renders the full page including JavaScript-generated content, making it ideal for archiving web pages, generating compliance snapshots, or creating offline copies of web content.
**Template-Based PDF Generation**
Generate professional documents from pre-built templates by sending structured JSON data. Available templates include:
- **Invoice Template** — Line items, tax calculation, company branding, payment terms, and client details
- **Receipt Template** — Transaction records with payment method, transaction ID, and itemized purchases
- **Report Template** — Multi-section business reports with executive summary, data sections, conclusions, and confidential markings
**PDF Merging**
Combine 2 to 20 separate PDF documents into a single merged file with one API call. Essential for assembling contract packages, combining multi-page reports, or bundling related documents for delivery.
**PDF Metadata Extraction**
Extract detailed information from any PDF file including page count, individual page dimensions (width and height), and document properties. Useful for validation, cataloging, and pre-processing PDF files in automated workflows.
## API Endpoints
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | /health | Health check and API status (no authentication required) |
| POST | /api/v1/pdf/from-html | Generate a PDF from an HTML string |
| POST | /api/v1/pdf/from-url | Generate a PDF from a webpage URL |
| POST | /api/v1/pdf/from-template | Generate a PDF from a pre-built template with dynamic data |
| POST | /api/v1/pdf/merge | Merge multiple PDF files into one document |
| POST | /api/v1/pdf/metadata | Extract page count and dimensions from a PDF |
## Customization Options
Every PDF generation endpoint supports extensive customization:
- **Page Format:** A3, A4, A5, Letter, Legal
- **Orientation:** Portrait or Landscape
- **Margins:** Custom top, right, bottom, and left margins in millimeters
- **Scale:** Adjust content scaling from 10% to 200%
- **Background Printing:** Include or exclude CSS background colors and images
- **Headers and Footers:** Custom HTML header and footer templates with page numbers
## Common Use Cases
**SaaS Platforms** — Automatically generate monthly invoices, usage reports, and export user data as downloadable PDF files directly from your application backend.
**E-Commerce and Retail** — Print itemized purchase receipts with payment method details (credit card, PayPal, M-Pesa, bank transfer) and transaction identifiers for customer records.
**Legal and Financial Services** — Merge multiple contract pages, NDAs, terms of service, and amendment documents into a single bundled PDF for client signatures.
**Freelancers and Agencies** — Create branded invoices with company logo, payment terms, and line-item billing in seconds without any design software.
**Healthcare and Medical** — Generate patient reports, discharge summaries, and appointment confirmations as secure PDF documents.
**Education** — Produce certificates, transcripts, and assessment reports from student data records.
**Real Estate** — Generate property listing sheets, rental agreements, and inspection reports from structured data.
## Security
This API has undergone a comprehensive 28-point security audit covering:
- Input validation on every endpoint using strict schema validation
- SSRF (Server-Side Request Forgery) protection blocking access to localhost, private IPs, and cloud metadata endpoints
- XSS prevention with HTML entity escaping in all templates
- Timing-safe API key authentication to prevent timing attacks
- Rate limiting per API key to prevent abuse
- Security headers including HSTS, Content Security Policy, and X-Frame-Options
- No storage of generated PDFs — documents are returned immediately and never persisted
## Integration Example
Generate an invoice PDF with a single HTTP request:
```
POST /api/v1/pdf/from-template
Content-Type: application/json
x-api-key: YOUR_API_KEY
{
"template": "invoice",
"data": {
"companyName": "Your Company",
"clientName": "Client Name",
"invoiceNumber": "INV-001",
"items": [
{
"description": "Consulting Services",
"quantity": 10,
"unitPrice": 150,
"amount": 1500
}
],
"total": 1500,
"currency": "USD"
}
}
```
Response: Raw PDF binary file (application/pdf content type)
## Performance
- Average response time: Under 400 milliseconds for HTML-to-PDF
- Concurrent request handling with a managed browser pool
- Circuit breaker pattern for automatic recovery from failures
- Request ID tracing on every API call for end-to-end observability
## Error Handling
All errors return structured JSON responses with:
- A machine-readable error code (VALIDATION_ERROR, UNAUTHORIZED, RATE_LIMITED, etc.)
- A human-readable error message explaining what went wrong
- A retryable flag indicating whether the request can be retried
No stack traces or internal server details are ever exposed to API consumers.
Check API status and uptime. Add ?deep=true to test the PDF rendering engine and get memory usage stats. No authentication required.
Health Check - Endpoint Features
| Object | Description |
|---|
{"status":"healthy","timestamp":"2026-03-13T14:10:46.756Z","uptime":154731,"version":"1.0.0"}
curl --location --request GET 'https://zylalabs.com/api/12011/html+to+pdf+generation+api/22873/health+check' --header 'Authorization: Bearer YOUR_API_KEY'
Parse a PDF document and extract detailed metadata including title, author, subject, creator, producer, creation date, modification date, total page count, and individual page dimensions (width and height in points). Send the PDF as a base64-encoded string. Maximum size: 50MB. Response is JSON.
Extract PDF Metadata - Endpoint Features
| Object | Description |
|---|---|
Request Body |
[Required] Json |
{"metadata":{"title":null,"author":null,"subject":null,"creator":"pdf-lib (https://github.com/Hopding/pdf-lib)","producer":"pdf-lib (https://github.com/Hopding/pdf-lib)","creationDate":"2026-03-13T14:13:21.000Z","modificationDate":"2026-03-13T14:13:21.000Z","pageCount":1,"pages":[{"index":0,"width":72,"height":72}]},"requestId":"ded7bd08-06c3-451d-8767-87516d81b086"}
curl --location --request POST 'https://zylalabs.com/api/12011/html+to+pdf+generation+api/22878/extract+pdf+metadata' --header 'Authorization: Bearer YOUR_API_KEY'
--data-raw '{
"pdf": "JVBERi0xLjcKCjEgMCBvYmogICUKPDwvVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCgoyIDAgb2JqCjw8L1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPj4KZW5kb2JqCgozIDAgb2JqCjw8L1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA3MiA3Ml0KPj4KZW5kb2JqCgp4cmVmCjAgNAowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMTAgMDAwMDAgbiAKMDAwMDAwMDA2MCAwMDAwMCBuIAowMDAwMDAwMTE2IDAwMDAwIG4gCnRyYWlsZXIKPDwvU2l6ZSA0Ci9Sb290IDEgMCBSCj4+CnN0YXJ0eHJlZgoxNzMKJSVFT0YK"
}'
| Header | Description |
|---|---|
Authorization
|
[Required] Should be Bearer access_key. See "Your API Access Key" above when you are subscribed. |
No long-term commitment. Upgrade, downgrade, or cancel anytime. Free Trial includes up to 50 requests.
Each endpoint returns specific data types: the HTML to PDF, URL to PDF, and template PDF generation endpoints return binary PDF files. The PDF merging endpoint also returns a binary PDF file. The metadata extraction endpoint returns a JSON object containing detailed metadata about the PDF, including title, author, and page count.
The key fields in the metadata extraction response include "title," "author," "subject," "creator," "producer," "creationDate," "modificationDate," and "pageCount." Each page's dimensions are also included in the "pages" array.
The HTML to PDF endpoint accepts parameters such as "html" (the HTML content), "filename" (the desired PDF filename), and "options" for customization, including "format" (A3, A4, etc.), "landscape" (true/false), "printBackground" (true/false), and "margin" settings.
The response data for the PDF merging endpoint is organized as a binary PDF file. The merged document contains all pages from the input PDFs in the order they were provided, ensuring a seamless combination of documents.
The PDF metadata extraction endpoint provides information such as the document's title, author, subject, creator, producer, creation and modification dates, total page count, and individual page dimensions, allowing for comprehensive document analysis.
Users can customize their requests by sending structured JSON data that includes specific fields relevant to the chosen template (invoice, receipt, or report). Each template allows for dynamic data input, such as line items for invoices or transaction details for receipts.
Typical use cases include generating downloadable invoices from HTML templates, archiving web pages as PDFs for compliance, and creating reports or dashboards that need to be shared in a portable format.
Users can save the binary PDF response directly to a file with a .pdf extension. This allows for easy sharing, printing, or archiving of documents generated through the API, ensuring they maintain the intended formatting and quality.
O endpoint de conversão de HTML para PDF aceita um tamanho máximo de HTML de 5MB. Para a mesclagem de PDFs, cada arquivo PDF deve ter um tamanho máximo de 50MB. O endpoint de extração de metadados também aceita PDFs de até 50MB.
Os usuários podem personalizar a aparência dos PDFs ajustando parâmetros como "formato" (A3, A4, etc.), "orientação" (retrato ou paisagem), "margens" (superior, inferior, etc.), e "impressão de fundo" (incluir ou excluir cores e imagens de fundo).
Se a solicitação falhar, a API retornará uma resposta JSON estruturada com um código de erro, uma mensagem explicativa e uma bandeira de repetição que indica se a solicitação pode ser repetida.
Para garantir a renderização correta, os usuários devem enviar HTML válido e bem estruturado, incluindo CSS compatível. A API suporta Flexbox, Grid e fontes personalizadas, permitindo uma formatação precisa.
Os modelos disponíveis incluem fatura (com itens de linha e detalhes de pagamento), recibo (com registros de transação) e relatório (com seções múltiplas e resumo executivo), permitindo a criação de documentos profissionais.
Os usuários podem mesclar de 2 a 20 PDFs enviando cada arquivo como uma string codificada em base64. A API retornará um único PDF que contém todas as páginas dos documentos de entrada na ordem fornecida.
Para processar uma URL, a página deve ser publicamente acessível. A API renderiza completamente a página, incluindo conteúdo gerado por JavaScript, mas bloqueia URLs que acessam localhost ou IPs privados por motivos de segurança.
Please have a look at our Refund Policy: https://zylalabs.com/terms#refund
To obtain your API key, you first need to sign in to your account and subscribe to the API you want to use. Once subscribed, go to your Profile, open the Subscription section, and select the specific API. Your API key will be available there and can be used to authenticate your requests.
You can’t switch APIs during the free trial. If you subscribe to a different API, your trial will end and the new subscription will start as a paid plan.
If you don’t cancel before the 7th day, your free trial will end automatically and your subscription will switch to a paid plan under the same plan you originally subscribed to, meaning you will be charged and gain access to the API calls included in that plan.
The free trial ends when you reach 50 API requests or after 7 days, whichever comes first.
No, the free trial is available only once, so we recommend using it on the API that interests you the most. Most of our APIs offer a free trial, but some may not include this option.
Yes, we offer a 7-day free trial that allows you to make up to 50 API calls at no cost, so you can test our APIs without any commitment.
Zyla API Hub is like a big store for APIs, where you can find thousands of them all in one place. We also offer dedicated support and real-time monitoring of all APIs. Once you sign up, you can pick and choose which APIs you want to use. Just remember, each API needs its own subscription. But if you subscribe to multiple ones, you'll use the same key for all of them, making things easier for you.
Service Level:
100%
Response Time:
3,591ms
Service Level:
100%
Response Time:
68ms
Service Level:
100%
Response Time:
3,976ms
Service Level:
91%
Response Time:
2,513ms
Service Level:
100%
Response Time:
652ms
Service Level:
100%
Response Time:
1,134ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
148ms
Service Level:
100%
Response Time:
7,660ms
Service Level:
100%
Response Time:
485ms
Service Level:
100%
Response Time:
20ms
Service Level:
100%
Response Time:
4,081ms
Service Level:
100%
Response Time:
1,098ms
Service Level:
94%
Response Time:
766ms
Service Level:
100%
Response Time:
19ms
Service Level:
100%
Response Time:
563ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
0ms