Enterprise API Documentation

    Complete API reference with request schema, parameter contracts, cURL examples, and sample responses.

    API Endpoints

    Switch between APIs

    Document APIs

    Security APIs

    Conversion APIs

    OCR APIs

    Utility APIs

    File Management

    Templates

    Generate PDF

    POST

    Generate PDF from URL or HTML/CSS. Supports paper sizes, margins, landscape, fonts, wait strategies, and dynamic params.

    https://pdfapihub.com/api/v1/generatePdf

    Parameters

    Field-level request contract for this endpoint

    ParameterTypeRequiredDescriptionExample
    urlstringConditionalTarget webpage URL. Required when html_content is not provided.https://example.com
    html_contentstringConditionalRaw HTML markup. Required when url is not provided.<h1>Hello</h1>
    css_contentstringNoCSS styles used with html_content.h1{font-size:32px;}
    paper_sizestringNoA0–A6, Letter, Legal, Tabloid, Ledger. Default A4.A4
    landscapebooleanNoLandscape orientation.false
    print_backgroundbooleanNoInclude CSS backgrounds. Default true.true
    displayHeaderFooterbooleanNoShow header/footer.false
    preferCSSPageSizebooleanNoPrefer CSS @page size over paper_size.false
    marginstring | objectNoPreset (none/small/medium/large) or object with top/right/bottom/left.medium
    viewPortWidthintegerNoViewport width. Default 1080.1080
    viewPortHeightintegerNoViewport height. Default 720.720
    fontstringNoGoogle Font names, pipe-separated.Inter|Roboto
    wait_untilstringNoload, domcontentloaded, networkidle, commit.load
    wait_tillintegerNoExtra delay in seconds after page load.2
    cookie_accept_textstringNoCookie consent button text to click (URL mode).Accept ALL
    dynamic_paramsobjectNoKey-value pairs for {{placeholder}} substitution.{"name":"Rishabh"}
    page_sizeintegerNoMax pages to return (capped by plan).10
    output_formatstringNourl (default), file, base64, binary, pdf.url
    output_filenamestringNoCustom output filename.report.pdf

    Request Body

    {
      "html_content": "<h1>Invoice #1234</h1>",
      "css_content": "h1 { font-size: 28px; }",
      "paper_size": "A4",
      "margin": "medium",
      "print_background": true,
      "output_format": "url"
    }
    Request JSON Schema (expanded)
    {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "description": "Target webpage URL. Required when html_content is not provided.",
          "example": "https://example.com"
        },
        "html_content": {
          "type": "string",
          "description": "Raw HTML markup. Required when url is not provided.",
          "example": "<h1>Hello</h1>"
        },
        "css_content": {
          "type": "string",
          "description": "CSS styles used with html_content.",
          "example": "h1{font-size:32px;}"
        },
        "paper_size": {
          "type": "string",
          "description": "A0–A6, Letter, Legal, Tabloid, Ledger. Default A4.",
          "example": "A4"
        },
        "landscape": {
          "type": "boolean",
          "description": "Landscape orientation.",
          "example": "false"
        },
        "print_background": {
          "type": "boolean",
          "description": "Include CSS backgrounds. Default true.",
          "example": "true"
        },
        "displayHeaderFooter": {
          "type": "boolean",
          "description": "Show header/footer.",
          "example": "false"
        },
        "preferCSSPageSize": {
          "type": "boolean",
          "description": "Prefer CSS @page size over paper_size.",
          "example": "false"
        },
        "margin": {
          "type": "string",
          "description": "Preset (none/small/medium/large) or object with top/right/bottom/left.",
          "example": "medium"
        },
        "viewPortWidth": {
          "type": "string",
          "description": "Viewport width. Default 1080.",
          "example": "1080"
        },
        "viewPortHeight": {
          "type": "string",
          "description": "Viewport height. Default 720.",
          "example": "720"
        },
        "font": {
          "type": "string",
          "description": "Google Font names, pipe-separated.",
          "example": "Inter|Roboto"
        },
        "wait_until": {
          "type": "string",
          "description": "load, domcontentloaded, networkidle, commit.",
          "example": "load"
        },
        "wait_till": {
          "type": "string",
          "description": "Extra delay in seconds after page load.",
          "example": "2"
        },
        "cookie_accept_text": {
          "type": "string",
          "description": "Cookie consent button text to click (URL mode).",
          "example": "Accept ALL"
        },
        "dynamic_params": {
          "type": "string",
          "description": "Key-value pairs for {{placeholder}} substitution.",
          "example": "{\"name\":\"Rishabh\"}"
        },
        "page_size": {
          "type": "string",
          "description": "Max pages to return (capped by plan).",
          "example": "10"
        },
        "output_format": {
          "type": "string",
          "description": "url (default), file, base64, binary, pdf.",
          "example": "url"
        },
        "output_filename": {
          "type": "string",
          "description": "Custom output filename.",
          "example": "report.pdf"
        }
      },
      "required": []
    }

    Sample Response

    {
      "success": true,
      "pdf_url": "https://cdn.pdfapihub.com/pdf/a1b2c3d4.pdf",
      "file_size_bytes": 84321,
      "file_deletion_date": "2026-05-04",
      "source_type": "html"
    }
    Response JSON Schema (expanded)
    {
      "type": "object",
      "properties": {
        "success": {
          "type": "boolean",
          "example": true
        },
        "data": {
          "type": "object",
          "description": "Endpoint-specific response payload."
        }
      }
    }

    cURL Example

    curl -X POST https://pdfapihub.com/api/v1/generatePdf \
      -H "CLIENT-API-KEY: your-api-key" \
      -H "Content-Type: application/json" \
      -d '{ "html_content": "<h1>Invoice #1234</h1>", "css_content": "h1 { font-size: 28px; }", "paper_size": "A4", "margin": "medium", "print_background": true, "output_format": "url" }'

    Authentication & Error Contracts

    Common and endpoint-specific API error responses

    Headers:
    CLIENT-API-KEY: <your-api-key>
    Content-Type: application/json
    
    Success HTTP status:
    200  Success
    CodeTypeReason
    400Invalid RequestMalformed JSON, invalid body shape, or missing required fields.
    401UnauthorizedMissing or invalid CLIENT-API-KEY.
    429Rate LimitedRequest quota exceeded for current API key.
    500Internal ErrorUnexpected processing failure.
    422Render Validation FailedInvalid URL, unsupported HTML payload, or rendering options conflict.

    OpenAPI Export

    Generate endpoint-level OpenAPI JSON for SDK/client generation

    {
      "openapi": "3.0.3",
      "info": {
        "title": "PDF API Hub - Generate PDF",
        "version": "1.0.0"
      },
      "paths": {
        "/generatePdf": {
          "post": {
            "summary": "Generate PDF from URL or HTML/CSS. Supports paper sizes, margins, landscape, fonts, wait strategies, and dynamic params.",
            "security": [
              {
                "ApiKeyAuth": []
              }
            ],
            "requestBody": {
              "required": true,
              "content": {
                "application/json": {
                  "schema": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string",
                        "description": "Target webpage URL. Required when html_content is not provided.",
                        "example": "https://example.com"
                      },
                      "html_content": {
                        "type": "string",
                        "description": "Raw HTML markup. Required when url is not provided.",
                        "example": "<h1>Hello</h1>"
                      },
                      "css_content": {
                        "type": "string",
                        "description": "CSS styles used with html_content.",
                        "example": "h1{font-size:32px;}"
                      },
                      "paper_size": {
                        "type": "string",
                        "description": "A0–A6, Letter, Legal, Tabloid, Ledger. Default A4.",
                        "example": "A4"
                      },
                      "landscape": {
                        "type": "boolean",
                        "description": "Landscape orientation.",
                        "example": "false"
                      },
                      "print_background": {
                        "type": "boolean",
                        "description": "Include CSS backgrounds. Default true.",
                        "example": "true"
                      },
                      "displayHeaderFooter": {
                        "type": "boolean",
                        "description": "Show header/footer.",
                        "example": "false"
                      },
                      "preferCSSPageSize": {
                        "type": "boolean",
                        "description": "Prefer CSS @page size over paper_size.",
                        "example": "false"
                      },
                      "margin": {
                        "type": "string",
                        "description": "Preset (none/small/medium/large) or object with top/right/bottom/left.",
                        "example": "medium"
                      },
                      "viewPortWidth": {
                        "type": "string",
                        "description": "Viewport width. Default 1080.",
                        "example": "1080"
                      },
                      "viewPortHeight": {
                        "type": "string",
                        "description": "Viewport height. Default 720.",
                        "example": "720"
                      },
                      "font": {
                        "type": "string",
                        "description": "Google Font names, pipe-separated.",
                        "example": "Inter|Roboto"
                      },
                      "wait_until": {
                        "type": "string",
                        "description": "load, domcontentloaded, networkidle, commit.",
                        "example": "load"
                      },
                      "wait_till": {
                        "type": "string",
                        "description": "Extra delay in seconds after page load.",
                        "example": "2"
                      },
                      "cookie_accept_text": {
                        "type": "string",
                        "description": "Cookie consent button text to click (URL mode).",
                        "example": "Accept ALL"
                      },
                      "dynamic_params": {
                        "type": "string",
                        "description": "Key-value pairs for {{placeholder}} substitution.",
                        "example": "{\"name\":\"Rishabh\"}"
                      },
                      "page_size": {
                        "type": "string",
                        "description": "Max pages to return (capped by plan).",
                        "example": "10"
                      },
                      "output_format": {
                        "type": "string",
                        "description": "url (default), file, base64, binary, pdf.",
                        "example": "url"
                      },
                      "output_filename": {
                        "type": "string",
                        "description": "Custom output filename.",
                        "example": "report.pdf"
                      }
                    },
                    "required": []
                  }
                }
              }
            },
            "responses": {
              "200": {
                "description": "Success",
                "content": {
                  "application/json": {
                    "schema": {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "example": true
                        },
                        "data": {
                          "type": "object",
                          "description": "Endpoint-specific response payload."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "components": {
        "securitySchemes": {
          "ApiKeyAuth": {
            "type": "apiKey",
            "in": "header",
            "name": "CLIENT-API-KEY"
          }
        }
      }
    }