← 返回
未分类 Key 中文

Generate PDF from HTML

Generate a PDF document from HTML content or a public URL. Supports custom page sizes, fonts, margins, viewport dimensions, dynamic parameter substitution, a...
根据HTML内容或公开URL生成PDF文档,支持自定义页面尺寸、字体、页边距、视口尺寸、动态参数替换等功能。
rishabhdugar rishabhdugar 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 689
下载
💾 1
安装
1
版本
#latest

概述

Generate PDF

What It Does

Generates a PDF document from either raw HTML content or a public URL using a headless Chromium browser. The API renders the page and returns the result as a downloadable URL, base64 string, or raw PDF file.

When to Use

  • Convert an HTML template (invoice, report, certificate) into a PDF
  • Take a PDF snapshot of a live webpage
  • Generate PDFs with dynamic data via placeholder substitution
  • Create PDFs with custom fonts, margins, and page sizes

Required Inputs

You must provide one of:

  • html_content — raw HTML string to render
  • url — a public URL to convert

Authentication

Send your API key in the CLIENT-API-KEY header.

Get your free API key at https://pdfapihub.com. Full API documentation is available at https://pdfapihub.com/docs.

Use Cases

  • Invoice Generation — Generate branded PDF invoices from HTML templates with dynamic customer data
  • Report Export — Convert dashboard or analytics HTML pages into downloadable PDF reports
  • Certificate Creation — Produce personalized certificates or diplomas with dynamic name/date substitution
  • Contract Generation — Create contracts from templates with client-specific details filled in
  • Resume/CV Export — Convert styled HTML resumes to PDF for download
  • Receipt Generation — Auto-generate PDF receipts for e-commerce transactions
  • Webpage Archival — Save a snapshot of any public webpage as a PDF for records

Key Options

ParameterDescription
------------------------
output_formaturl (default), base64, file/pdf/binary
paper_sizeA4, A3, A5, Letter, Legal, Tabloid
landscapetrue for landscape orientation
marginObject with top, right, bottom, left (e.g. "10mm")
fontGoogle Font names, pipe-separated
dynamic_paramsKey-value object for {{placeholder}} replacement
wait_tillSeconds to wait before rendering (for JS-heavy pages)

Example Usage

curl -X POST https://pdfapihub.com/api/v1/generatePdf \
  -H "CLIENT-API-KEY: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "html_content": "<html><body><h1>Invoice #{{invoice_id}}</h1><p>Total: {{total}}</p></body></html>",
    "css_content": "body { font-family: Arial; }",
    "dynamic_params": { "invoice_id": "INV-001", "total": "$1,249.00" },
    "paper_size": "A4",
    "output_format": "url"
  }'

Notes

  • Boolean fields accept string values: "true", "1", "yes", "on"
  • Files are automatically deleted after 30 days
  • Page count limits are tier-dependent

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 04:05 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

PDF Parse

rishabhdugar
将 PDF 解析为结构化 JSON:包含文本、带有边界框的布局感知块、表格和图片元数据。
★ 0 📥 489

Document to PDF

rishabhdugar
通过PDFAPIHub云API将office文档(DOCX、DOC、PPT、PPTX、XLS、XLSX、CSV、TXT、ODT、RTF)转换为PDF,文档上传至pdfapihub.com完成转换。
★ 0 📥 826

Generate Image

rishabhdugar
使用无头 Chromium 将 HTML 内容或公开 URL 生成PNG 图片,支持自定义尺寸、Retina 高清、全页面截图以及 Cookie 配置。
★ 0 📥 538