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

# PDF Generator



## OpenAPI

````yaml POST /url2pdf
openapi: 3.1.0
info:
  title: Geekflare
  description: Official OpenAPI specification for all Geekflare endpoints.
  version: 1.0.0
  license:
    name: MIT
servers:
  - url: https://api.geekflare.com
security:
  - x-api-key: []
paths:
  /url2pdf:
    post:
      tags:
        - api-tool
      summary: Capture a full-page Url2Pdf of a website
      operationId: url2Pdf
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Url2PdfDto'
      responses:
        '200':
          description: Successfully captured Url2Pdf
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Url2PdfResponseDto'
        '400':
          description: Invalid URL.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BaseErrorResponseDto'
              example:
                timestamp: 1700000000000
                apiStatus: failure
                apiCode: 400
                message: INVALID_URL
                details: The URL must be a valid HTTP or HTTPS URL.
        '422':
          description: Unable to connect to the target website.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BaseErrorResponseDto'
              example:
                timestamp: 1700000000000
                apiStatus: failure
                apiCode: 422
                message: UNABLE_TO_CONNECT
                details: >-
                  The destination server could not be resolved, refused the
                  connection, timed out, or is redirecting indefinitely.
        '500':
          description: PDF conversion failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BaseErrorResponseDto'
              example:
                timestamp: 1700000000000
                apiStatus: failure
                apiCode: 500
                message: PDF_CONVERSION_FAILED
                details: >-
                  Our PDF conversion service encountered an error while fetching
                  the target URL.
components:
  schemas:
    Url2PdfDto:
      type: object
      properties:
        url:
          type: string
          description: Target URL
          example: https://example.com
        device:
          type: string
          description: Device type to emulate. Defaults to desktop.
          example: desktop
          enum:
            - desktop
            - mobile
          default: desktop
        proxyCountry:
          type: string
          description: Proxy country code to route the request
          example: us
        format:
          type: string
          description: Paper format
          example: a4
          enum:
            - letter
            - legal
            - a0
            - a1
            - a2
            - a3
            - a4
            - a5
            - a6
          default: a4
        orientation:
          type: string
          description: Orientation
          example: portrait
          enum:
            - portrait
            - landscape
          default: portrait
        margin:
          description: Margins in mm
          allOf:
            - $ref: '#/components/schemas/MarginDto'
        scale:
          type: number
          description: Rendering scale between 0–2
          example: 1.5
          default: 1
        hideCookie:
          type: boolean
          description: Hide cookie popups
          example: false
          default: false
        skipCaptcha:
          type: boolean
          description: Try to skip captcha
          example: false
          default: false
        addTimestamp:
          type: boolean
          description: Add timestamp watermark
          example: false
          default: false
      required:
        - url
    Url2PdfResponseDto:
      type: object
      properties:
        timestamp:
          type: number
          description: Timestamp of the request in milliseconds
          example: 1783943217189
        apiStatus:
          type: string
          description: API status message
          example: success
          enum:
            - success
            - failure
        apiCode:
          type: number
          description: API status code
          example: 200
        meta:
          description: Metadata about the request
          allOf:
            - $ref: '#/components/schemas/Url2PdfMetaDto'
        data:
          type: string
          description: Generated PDF URL
          example: >-
            https://api-assets.example.com/tests/pdf/o5jiqf08bmp93jsll7vb24vs.pdf
      required:
        - timestamp
        - apiStatus
        - apiCode
        - meta
        - data
    BaseErrorResponseDto:
      type: object
      properties:
        timestamp:
          type: number
          description: Timestamp of the request in milliseconds
          example: 1778737930991
        apiStatus:
          type: string
          description: API status message
          example: success
          enum:
            - success
            - failure
        apiCode:
          type: number
          description: API status code
          example: 200
        message:
          type: string
          description: Error message
          example: Invalid URL provided
        details:
          type: string
          description: Detailed error information
          example: The URL must be a valid HTTP or HTTPS URL
      required:
        - timestamp
        - apiStatus
        - apiCode
        - message
    MarginDto:
      type: object
      properties:
        top:
          type: number
          description: Top margin in mm
          example: 25.4
        bottom:
          type: number
          description: Bottom margin in mm
          example: 25.4
        right:
          type: number
          description: Right margin in mm
          example: 25.4
        left:
          type: number
          description: Left margin in mm
          example: 25.4
    Url2PdfMetaDto:
      type: object
      properties:
        url:
          type: string
          description: The target URL
          example: https://example.com
        device:
          type: string
          description: Device type used
          example: desktop
        proxyCountry:
          type: string
          description: Proxy country used, if any
        format:
          type: string
          description: Paper format
          example: letter
        orientation:
          type: string
          description: Orientation
          example: landscape
        margin:
          description: Margins in mm
          allOf:
            - $ref: '#/components/schemas/MarginDto'
        scale:
          type: number
          description: Rendering scale
          example: 1.5
        test:
          description: Test details
          allOf:
            - $ref: '#/components/schemas/TestMetaDto'
      required:
        - url
        - device
        - format
        - orientation
        - scale
        - test
    TestMetaDto:
      type: object
      properties:
        id:
          type: string
          description: Unique test identifier
          example: mxqx9v9y0742lap6altwdteqd28t23nq
      required:
        - id
  securitySchemes:
    x-api-key:
      type: apiKey
      in: header
      name: x-api-key
      description: API Key required for all endpoints

````