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

# Generate PDF from Markdown

> Converts markdown content to PDF with customizable styling options.



## OpenAPI

````yaml api-reference/openapi.json post /pdf/markdown
openapi: 3.1.0
info:
  title: refile API
  description: API for converting Markdown to PDF with various styling options
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://www.refile.co/api/v1
security:
  - bearerAuth: []
paths:
  /pdf/markdown:
    post:
      summary: Generate PDF from Markdown
      description: Converts markdown content to PDF with customizable styling options.
      operationId: generatePdfFromMarkdown
      requestBody:
        description: Markdown content and formatting options
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MarkdownPayload'
        required: true
      responses:
        '200':
          description: PDF generated successfully
          content:
            application/pdf:
              schema:
                type: string
                format: binary
                description: Generated PDF file (when output=binary)
              example:
                url: >-
                  https://files.refile.co/pdf/a1b2c3d4-e5f6-7g8h-9i0j-k1l2m3n4o5p6.pdf
            application/json:
              schema:
                $ref: '#/components/schemas/UrlResponse'
                description: URL to the generated PDF (when output=url)
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Insufficient permissions or out of credits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: File size exceeds the limit for hosted files
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    MarkdownPayload:
      required:
        - markdown
      type: object
      properties:
        markdown:
          type: string
          minLength: 1
          description: The markdown content to convert to PDF.
        output:
          type: string
          enum:
            - binary
            - url
          default: binary
          description: >-
            The format of the output. URL will return a direct link to the PDF,
            binary returns the PDF directly.
        theme:
          type: string
          enum:
            - basic
            - modern
          default: modern
          description: The theme to use for the PDF.
        pageNumeration:
          type: string
          enum:
            - none
            - center
            - left
            - right
          default: center
          description: The position of the page numeration.
        pageSize:
          type: string
          enum:
            - A0
            - A1
            - A2
            - A3
            - A4
            - A5
            - A6
            - A7
            - A8
            - A9
            - Letter
            - B1
            - B2
            - B3
            - B4
            - B5
            - B6
            - Ledger
            - Legal
            - Executive
            - Folio
            - Tabloid
          default: A4
          description: The size of the page to use for the PDF.
    UrlResponse:
      type: object
      properties:
        url:
          type: string
          description: URL to access the generated PDF
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message describing what went wrong
        details:
          type: object
          description: Additional details about the error (if available)
        message:
          type: string
          description: Error name or type (if available)
        hint:
          type: string
          description: Suggested solution to fix the error (if available)
        size:
          type: string
          description: File size information (for size-related errors)
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````