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

    Generate PDF

    POST

    Generate PDF from URL or HTML/CSS input.

    https://pdfapihub.com/api/v1/generatePdf
    output_format: url
    output_format: file

    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;}
    wait_tillnumberNoWait time in ms before rendering screenshot/PDF.10000
    full_pagebooleanNoCapture full scroll height for URL rendering.true
    viewPortWidthnumberNoViewport width in px.1080
    viewPortHeightnumberNoViewport height in px.720
    output_format"url" | "file"NoReturn file URL or binary file response.url
    output_filenamestringNoOutput filename (without extension).document

    Request Body

    {
      "url": "https://example.com",
      "full_page": true,
      "wait_till": 10000,
      "viewPortWidth": 1080,
      "viewPortHeight": 720,
      "output_format": "url",
      "output_filename": "document"
    }
    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;}"
        },
        "wait_till": {
          "type": "number",
          "description": "Wait time in ms before rendering screenshot/PDF.",
          "example": "10000"
        },
        "full_page": {
          "type": "boolean",
          "description": "Capture full scroll height for URL rendering.",
          "example": "true"
        },
        "viewPortWidth": {
          "type": "number",
          "description": "Viewport width in px.",
          "example": "1080"
        },
        "viewPortHeight": {
          "type": "number",
          "description": "Viewport height in px.",
          "example": "720"
        },
        "output_format": {
          "type": "string",
          "description": "Return file URL or binary file response.",
          "example": "url"
        },
        "output_filename": {
          "type": "string",
          "description": "Output filename (without extension).",
          "example": "document"
        }
      },
      "required": []
    }

    Sample Response

    {
      "success": true,
      "pdf_url": "https://storage.example.com/document-a1b2.pdf"
    }
    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 '{ "url": "https://example.com", "full_page": true, "wait_till": 10000, "viewPortWidth": 1080, "viewPortHeight": 720, "output_format": "url", "output_filename": "document" }'

    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 input.",
            "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;}"
                      },
                      "wait_till": {
                        "type": "number",
                        "description": "Wait time in ms before rendering screenshot/PDF.",
                        "example": "10000"
                      },
                      "full_page": {
                        "type": "boolean",
                        "description": "Capture full scroll height for URL rendering.",
                        "example": "true"
                      },
                      "viewPortWidth": {
                        "type": "number",
                        "description": "Viewport width in px.",
                        "example": "1080"
                      },
                      "viewPortHeight": {
                        "type": "number",
                        "description": "Viewport height in px.",
                        "example": "720"
                      },
                      "output_format": {
                        "type": "string",
                        "description": "Return file URL or binary file response.",
                        "example": "url"
                      },
                      "output_filename": {
                        "type": "string",
                        "description": "Output filename (without extension).",
                        "example": "document"
                      }
                    },
                    "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"
          }
        }
      }
    }