๐Ÿงพ Generating PDFs from HTML

Outliny allows you to generate beautiful, production-ready PDFs directly from raw HTML content. This is perfect if you already have a custom HTML layout or generate your document content dynamically.

What is HTML-to-PDF Generation?

  • Instead of using a pre-designed template, you provide your own HTML code (optionally with inline CSS), and Outliny will render it into a clean, printable PDF file.
  • It's fast, flexible, and gives you full control over layout and styling.

Endpoint

  • POST /api/v1/render/pdf/html

Authentication

  • Like all API requests, you must include your API Key:
  • Authorization: Bearer YOUR_API_KEY

Request Body

FieldTypeRequiredDescription
htmlstringOptionalThe full HTML content you want to render.
filenamestringOptionalSuggested filename for the generated PDF.
output_typestringOptionalpdf (default) or base64.
page_settingsstringOptionalCustomize page size, margins, orientation, etc.

Example Request

POST https://api.outliny.com/api/v1/render/pdf/html
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "html": "<html><body><h1>Invoice #12345</h1><p>Thank you for your business!</p></body></html>",
  "filename": "invoice-12345.pdf",
  "page_settings": {
    "format": "A4",
    "margin": "20mm",
    "orientation": "portrait"
  }
}

OR

curl -X POST "https://outliny.com/api/getHtml" -H "Content-Type: application/json" -d
    '{
      "templateID": "67eb70b13db38972948a2597",
      "jsonData": {}
    }'

Response

FieldTypeDescription
statusstringsuccess
file_urlstring (If output is URL) Downloadable link
file_base64string(If output is base64) Encoded file content.

Example Response

{
  "status": "success",
  "file_url": "https://api.outliny.com/files/generated/invoice-12345.pdf"
}

Or, if output_type: base64:

{
  "status": "success",
  "file_base64": "JVBERi0xLjQKJc..."
}

๐Ÿ“ Page Settings Options

FieldTypeDescription
formatPaper size (A4, Letter, etc.)A4
orientationportrait or landscapeportrait
marginMargin size (e.g., "10mm", "1in")20mm

Default settings:

  • Format: A4
  • Orientation: portrait
  • Margin: 10mm

Best Practices for HTML-to-PDF

  • Use inline styles (style="") where possible for more consistent rendering.
  • Avoid using external CSS links โ€” embed your styles inside tags.
  • Test your HTML for print-friendliness: avoid heavy scripts or non-printable elements.
  • Keep content within standard page widths (~600pxโ€“800px) for best PDF layout.
  • Use CSS @media print rules if needed for precise formatting.

Start Generating PDFs from HTML Today!

  • Explore Full API Docs
  • Learn More About Advanced PDF Options