> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autype.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Convert HTML to PDF

> Convert an HTML file to a high-quality PDF. Supports custom page settings, margins, headers, footers with page numbers, and CSS media emulation for framework compatibility.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/dev/tools/convert/html-to-pdf
openapi: 3.0.0
info:
  title: Autype Developer API
  description: >-
    Autype Developer API for programmatic document generation.


    ## Authentication

    Use an API key in `X-API-Key`. Autype's trusted MCP service may instead use
    a short-lived, Developer-API-audience OAuth token obtained through
    server-side token exchange. Raw MCP resource tokens, login JWTs, and
    third-party tokens are not accepted.


    ## Rate Limiting

    API requests are rate-limited to 100 requests per minute per API key.


    ## Automation Credits

    Developer API rendering and bulk operations consume automation credits from
    your organization. AI documents, assistant tasks, translations, and AI
    images use separate plan allowances.
  version: '1.0'
  contact: {}
servers:
  - url: https://api.autype.com
    description: Production
security: []
tags:
  - name: Temporary Images
    description: Upload and manage temporary images for document rendering
  - name: Render
    description: Render documents to PDF, DOCX, ODT, or page images
  - name: Bulk Render
    description: Bulk document generation with variable substitution
  - name: Documents
    description: Document variable inspection
  - name: Projects
    description: List organization projects
paths:
  /api/v1/dev/tools/convert/html-to-pdf:
    post:
      tags:
        - developer-api
      summary: Convert HTML to PDF
      description: >-
        Convert an HTML file to a high-quality PDF. Supports custom page
        settings, margins, headers, footers with page numbers, and CSS media
        emulation for framework compatibility.
      operationId: ToolsController_convertHtmlToPdf_v1
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConvertHtmlToPdfDto'
      responses:
        '201':
          description: Conversion job created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolsJobResponseDto'
      security:
        - mcp-oauth: []
        - api-key: []
components:
  schemas:
    ConvertHtmlToPdfDto:
      type: object
      properties:
        fileId:
          type: string
          description: File ID of the HTML file to convert
          example: 550e8400-e29b-41d4-a716-446655440000
        landscape:
          type: string
          description: 'Page orientation. Default: "portrait"'
          enum:
            - portrait
            - landscape
          example: portrait
        format:
          type: string
          description: 'Page format. Default: "A4". Ignored when preferCssPageSize is true.'
          enum:
            - A4
            - A3
            - A5
            - Letter
            - Legal
            - Tabloid
          example: A4
        emulatedMediaType:
          type: string
          description: >-
            CSS media type emulation. Use "screen" to preserve CSS framework
            styles (e.g. Tailwind, Bootstrap). Default: "print"
          enum:
            - screen
            - print
          example: print
        margin:
          description: 'Page margins. Defaults: top/bottom 20mm, left/right 15mm.'
          allOf:
            - $ref: '#/components/schemas/HtmlToPdfMarginDto'
        scale:
          type: number
          description: >-
            Scale of the webpage rendering. Must be between 0.1 and 2.0.
            Default: 1.0
          example: 1
          minimum: 0.1
          maximum: 2
        preferCssPageSize:
          type: boolean
          description: >-
            Give any CSS @page size declared in the HTML priority over the
            format option. Default: false
          example: false
        headerTemplate:
          type: string
          description: >-
            HTML template for the page header. Use the following placeholders:
            <span class="pageNumber"></span> for current page, <span
            class="totalPages"></span> for total pages. Must be valid HTML.
            Requires a non-zero top margin.
          example: >-
            <div style="font-size:10px;text-align:center;width:100%;"><span
            class="pageNumber"></span> / <span class="totalPages"></span></div>
        footerTemplate:
          type: string
          description: >-
            HTML template for the page footer. Use the following placeholders:
            <span class="pageNumber"></span> for current page, <span
            class="totalPages"></span> for total pages. Must be valid HTML.
            Requires a non-zero bottom margin.
          example: >-
            <div style="font-size:10px;text-align:center;width:100%;">Page <span
            class="pageNumber"></span> of <span class="totalPages"></span></div>
        webhook:
          description: Optional webhook configuration
          allOf:
            - $ref: '#/components/schemas/WebhookConfigDto'
      required:
        - fileId
    ToolsJobResponseDto:
      type: object
      properties:
        id:
          type: string
          description: Job ID
          example: 550e8400-e29b-41d4-a716-446655440000
        action:
          type: string
          description: Action that was performed
          example: pdf.merge
        status:
          type: string
          description: Current job status
          enum:
            - PENDING
            - PROCESSING
            - COMPLETED
            - FAILED
          example: PENDING
        inputFileIds:
          description: Input file IDs used for this job
          example:
            - file-id-1
          type: array
          items:
            type: string
        outputFileId:
          type: object
          description: Output file ID (available when COMPLETED)
          nullable: true
          example: null
        error:
          type: object
          description: Error message (available when FAILED)
          nullable: true
          example: null
        result:
          type: object
          description: >-
            Structured job result data (e.g. OCR markdown/JSON, generated
            filename, PDF metadata, form fields). Available when the job
            produces a direct result instead of an output file.
        metadata:
          type: object
          description: >-
            **Deprecated** — use `result` instead. Additional metadata,
            duplicated from result for backward compatibility.
          deprecated: true
        createdAt:
          format: date-time
          type: string
          description: Job creation timestamp
        startedAt:
          type: object
          description: Job start timestamp
          nullable: true
        completedAt:
          type: object
          description: Job completion timestamp
          nullable: true
      required:
        - id
        - action
        - status
        - inputFileIds
        - outputFileId
        - error
        - createdAt
        - startedAt
        - completedAt
    HtmlToPdfMarginDto:
      type: object
      properties:
        top:
          type: string
          description: Top margin (e.g. "20mm", "1in", "2cm")
          example: 20mm
        right:
          type: string
          description: Right margin (e.g. "15mm", "1in", "2cm")
          example: 15mm
        bottom:
          type: string
          description: Bottom margin (e.g. "20mm", "1in", "2cm")
          example: 20mm
        left:
          type: string
          description: Left margin (e.g. "15mm", "1in", "2cm")
          example: 15mm
    WebhookConfigDto:
      type: object
      properties:
        webhookUrl:
          type: string
          example: https://example.com/webhook
          description: URL to receive a POST notification when the job completes or fails
        webhookAuth:
          description: >-
            Optional authentication for the webhook request (custom header or
            Basic Auth)
          allOf:
            - $ref: '#/components/schemas/WebhookAuthDto'
    WebhookAuthDto:
      type: object
      properties:
        headerName:
          type: string
          example: X-API-Key
          description: Custom header name
        headerValue:
          type: string
          example: my-secret-key
          description: Custom header value
        basicAuthUsername:
          type: string
          example: user
          description: Username for Basic Auth
        basicAuthPassword:
          type: string
          example: pass
          description: Password for Basic Auth
  securitySchemes:
    mcp-oauth:
      scheme: bearer
      bearerFormat: Autype Developer API OAuth token
      type: http
      description: >-
        Short-lived, Developer-API-audience token obtained by the trusted MCP
        service through token exchange (mcp_at_...). Raw MCP resource tokens are
        rejected.
    api-key:
      type: apiKey
      in: header
      name: X-API-Key
      description: API Key (starts with ak_...)

````