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

# Create PDF

> Convert HTML content to PDF with optional formatting options



## OpenAPI

````yaml POST /api/pdf
openapi: 3.1.0
info:
  title: Peedief API
  description: Convert HTML to PDF with Peedief API
  version: 1.0.0
servers:
  - url: https://peedief.com
security:
  - apiKeyAuth: []
paths:
  /api/pdf:
    post:
      summary: Generate PDF from HTML
      description: Convert HTML content to PDF with optional formatting options
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PDFRequest'
      responses:
        '200':
          description: PDF generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PDFResponse'
        '400':
          description: Bad request - invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized - invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    PDFRequest:
      type: object
      required:
        - html
      properties:
        html:
          type: string
          description: HTML content to convert to PDF
        fileName:
          type: string
          description: Name for the generated PDF file
          default: document.pdf
        options:
          $ref: '#/components/schemas/PDFOptions'
    PDFResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Whether the PDF generation was successful
        downloadUrl:
          type: string
          description: URL to download the generated PDF
        previewUrl:
          type: string
          description: Embeddable URL to preview the generated PDF in an iframe
        fileName:
          type: string
          description: Name of the generated PDF file
        fileSize:
          type: integer
          description: Size of the generated PDF in bytes
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: Error message
        details:
          type: array
          description: Additional error details (for validation errors)
          items:
            type: object
    PDFOptions:
      type: object
      properties:
        format:
          type: string
          description: Page format
          enum:
            - A4
            - A3
            - Letter
          default: A4
        landscape:
          type: boolean
          description: Page orientation
          default: false
        printBackground:
          type: boolean
          description: Include CSS backgrounds and images
          default: true
        margin:
          $ref: '#/components/schemas/PDFMargin'
        scale:
          type: number
          description: Zoom level from 0.1 to 2.0
          minimum: 0.1
          maximum: 2
          default: 1
    PDFMargin:
      type: object
      properties:
        top:
          type: string
          description: Top margin (e.g., '20mm')
          default: 20mm
        bottom:
          type: string
          description: Bottom margin (e.g., '20mm')
          default: 20mm
        left:
          type: string
          description: Left margin (e.g., '15mm')
          default: 15mm
        right:
          type: string
          description: Right margin (e.g., '15mm')
          default: 15mm
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````