Pricing
from $14.00 / 1,000 results
Go to Apify Store
Html To Pdf Api
Deprecated๐ Convert any HTML page or URL to high-quality PDF documents via API. Perfect for reports, invoices, documentation, web page archiving, and automated document generation.
Pricing
from $14.00 / 1,000 results
Rating
0.0
(0)
Developer
Actor stats
0
Bookmarked
1
Total users
1
Monthly active users
5 months ago
Last modified
Categories
Share
๐ Convert any HTML page or URL to high-quality PDF documents via API. Perfect for reports, invoices, documentation, web page archiving, and automated document generation.
๐ Key Features
| Feature | Description |
|---|---|
| ๐ High Quality PDFs | Professional PDF generation with full formatting |
| ๐ URL or HTML | Convert URLs or raw HTML content |
| ๐ Custom Format | A4, Letter, Legal, and more page formats |
| ๐ Landscape/Portrait | Choose orientation |
| ๐จ Full Styling | Includes backgrounds, colors, and graphics |
| โฑ๏ธ Smart Waiting | Wait for selectors before PDF generation |
| ๐ Header/Footer | Custom headers and footers with page numbers |
| ๐ Public URLs | Direct download URLs for your PDFs |
๐ฅ Input
Required
url(string):- URL to convert to PDF, OR
- Raw HTML content (if
htmlContent: true) - Example:
"https://example.com"or"<html><body>Hello</body></html>"
Optional
htmlContent(boolean, default: false): Set totrueifurlcontains raw HTMLformat(string, default: "A4"): Page format (A4, Letter, Legal, Tabloid, Ledger, A0-A6)landscape(boolean, default: false): Print in landscape orientationmarginTop(string, default: "1cm"): Top margin in CSS units (e.g., "1cm", "10mm", "1in")marginRight(string, default: "1cm"): Right margin in CSS unitsmarginBottom(string, default: "1cm"): Bottom margin in CSS unitsmarginLeft(string, default: "1cm"): Left margin in CSS unitsdisplayHeaderFooter(boolean, default: false): Show header/footerheaderTemplate(string): HTML template for header (supportsdate,title,url,pageNumber,totalPages)footerTemplate(string): HTML template for footerprintBackground(boolean, default: true): Include background graphicsscale(number, default: 1): Scale factor (0.1 to 2)waitForSelector(string): CSS selector to wait for before generating PDFwaitTimeout(number, default: 30000): Max wait time in milliseconds
๐ค Output
Returns PDF metadata with download URL:
{"url":"https://example.com","pdfKey":"pdf-1234567890-abc123.pdf","pdfUrl":"https://api.apify.com/v2/key-value-stores/.../pdf-1234567890-abc123.pdf","format":"A4","landscape":false,"pageCount":3,"fileSize":145678,"timestamp":"2024-01-01T12:00:00.000Z","_metadata":{"runId":"abc123","actorId":"user/html-to-pdf-api","processedAt":"2024-01-01T12:00:00.000Z","processingTimeMs":3500}}
๐ก Use Cases
- โ Invoice Generation - Convert HTML invoices to PDF
- โ Report Creation - Generate PDF reports from web dashboards
- โ Documentation - Archive web pages as PDFs
- โ Email Attachments - Generate PDFs for email campaigns
- โ Legal Documents - Convert contracts and agreements
- โ Receipts & Statements - Generate printable documents
- โ Web Page Archiving - Save web pages as PDFs
๐ Examples
Basic URL to PDF
{"url":"https://example.com"}
HTML Content to PDF
{"url":"<html><body><h1>Hello World</h1><p>This is a PDF!</p></body></html>","htmlContent":true}
Custom Format with Header/Footer
{"url":"https://example.com","format":"Letter","landscape":true,"displayHeaderFooter":true,"headerTemplate":"<div style='font-size:10px; text-align:center; width:100%;'><span class='title'></span></div>","footerTemplate":"<div style='font-size:10px; text-align:center; width:100%;'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>"}
Wait for Content to Load
{"url":"https://example.com/dashboard","waitForSelector":".chart-container","waitTimeout":10000}
๐ Notes
- PDFs are stored securely and accessible via public URLs
- Large pages may take longer to generate
- Use
waitForSelectorfor pages with dynamic content that needs time to load - Header/footer templates support CSS styling and special variables:
date,title,url,pageNumber,totalPages
