Html To Pdf Api avatar
Html To Pdf Api
Under maintenance

Pricing

from $14.00 / 1,000 results

Go to Apify Store
Html To Pdf Api

Html To Pdf Api

Under maintenance

πŸ“„ 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

SimplifySME Toolbox

SimplifySME Toolbox

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

1

Monthly active users

5 days ago

Last modified

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

FeatureDescription
πŸ“„ High Quality PDFsProfessional PDF generation with full formatting
🌐 URL or HTMLConvert URLs or raw HTML content
πŸ“ Custom FormatA4, Letter, Legal, and more page formats
πŸ”„ Landscape/PortraitChoose orientation
🎨 Full StylingIncludes backgrounds, colors, and graphics
⏱️ Smart WaitingWait for selectors before PDF generation
πŸ“Š Header/FooterCustom headers and footers with page numbers
πŸ”— Public URLsDirect 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 to true if url contains raw HTML
  • format (string, default: "A4"): Page format (A4, Letter, Legal, Tabloid, Ledger, A0-A6)
  • landscape (boolean, default: false): Print in landscape orientation
  • marginTop (string, default: "1cm"): Top margin in CSS units (e.g., "1cm", "10mm", "1in")
  • marginRight (string, default: "1cm"): Right margin in CSS units
  • marginBottom (string, default: "1cm"): Bottom margin in CSS units
  • marginLeft (string, default: "1cm"): Left margin in CSS units
  • displayHeaderFooter (boolean, default: false): Show header/footer
  • headerTemplate (string): HTML template for header (supports date, title, url, pageNumber, totalPages)
  • footerTemplate (string): HTML template for footer
  • printBackground (boolean, default: true): Include background graphics
  • scale (number, default: 1): Scale factor (0.1 to 2)
  • waitForSelector (string): CSS selector to wait for before generating PDF
  • waitTimeout (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 waitForSelector for pages with dynamic content that needs time to load
  • Header/footer templates support CSS styling and special variables: date, title, url, pageNumber, totalPages