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

# Create PDF format from a document or image

> Converts an uploaded Word document or supported image to a PDF file by creating a new PDF format representation. Supported inputs are Word, PNG, and JPEG. Returns the new PDF document's metadata.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/samplehc/openapi.documented.yml post /api/v2/documents/{documentId}/formats/pdf
openapi: 3.0.3
info:
  title: Sample Healthcare API
  description: API for Sample Healthcare
  version: 1.0.0
servers: []
security: []
paths:
  /api/v2/documents/{documentId}/formats/pdf:
    post:
      tags:
        - Document
      summary: Create PDF format from a document or image
      description: >-
        Converts an uploaded Word document or supported image to a PDF file by
        creating a new PDF format representation. Supported inputs are Word,
        PNG, and JPEG. Returns the new PDF document's metadata.
      parameters:
        - schema:
            type: string
          in: path
          name: documentId
          required: true
          description: The unique identifier of the document or image to convert.
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
                - not: {}
                - type: object
                  properties:
                    mimeType:
                      type: string
                    fileName:
                      type: string
                  additionalProperties: false
      responses:
        '200':
          description: Successfully converted the document to PDF.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  fileName:
                    type: string
                required:
                  - id
                  - fileName
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The error message.
                  message:
                    type: string
                    description: The message.
                  statusCode:
                    type: number
                    description: The status code.
                  details:
                    type: object
                    additionalProperties: {}
                    description: The details of the error
                additionalProperties: true
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: >-
                      Not Found, the document with the specified ID does not
                      exist.
                required:
                  - error
                additionalProperties: false
        '500':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Internal server error during the conversion process.
                required:
                  - error
                additionalProperties: false
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from samplehc import SampleHealthcare

            client = SampleHealthcare(
                api_key=os.environ.get("SAMPLEHC_API_KEY"),  # This is the default and can be omitted
            )
            response = client.v2.documents.formats.create_pdf(
                document_id="documentId",
            )
            print(response.id)

````