Generate PDF from HTML
简介
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...
通过你的 Agent 添加
安装目录:generate-pdf/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: generate-pdf
description: "Generate a PDF document from HTML content or a public URL. Supports custom page sizes, fonts, margins, viewport dimensions, dynamic parameter substitution, and multiple output formats."
Generate PDF
What It Does
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 renderurl— 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
Parameter
Description
output_format
url (default), base64, file/pdf/binary
paper_size
A4, A3, A5, Letter, Legal, Tabloid
landscape
true for landscape orientation
margin
Object with top, right, bottom, left (e.g. "10mm")
font
Google Font names, pipe-separated
dynamic_params
Key-value object for {{placeholder}} replacement
wait_till
Seconds 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
| Parameter | Description |
|---|---|
output_format |
url (default), base64, file/pdf/binary |
paper_size |
A4, A3, A5, Letter, Legal, Tabloid |
landscape |
true for landscape orientation |
margin |
Object with top, right, bottom, left (e.g. "10mm") |
font |
Google Font names, pipe-separated |
dynamic_params |
Key-value object for {{placeholder}} replacement |
wait_till |
Seconds 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
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"
}'
- Boolean fields accept string values:
"true","1","yes","on" - Files are automatically deleted after 30 days
- Page count limits are tier-dependent
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。