---
title: "Compare Documents (Rich Text)"
method: POST
path: "/document/richtext"
---

# Compare Documents (Rich Text)

`POST /document/richtext`

## Request

- Base URL: `https://api.diffchecker.com/public`
- URL: `https://api.diffchecker.com/public/document/richtext`
- Auth: one of:
  - API key in header `X-Api-Key`
  - API key in query parameter `email`

Compute a rich-text diff between two PDFs with polygon geometry and optional visual object comparisons. Supports multipart/form-data uploads and JSON with base64-encoded data URLs.

## Query parameters

- `email` string, email
- `output_type` 'json' | 'html' | 'html_json' | 'pdf', required
- `input_type` 'json' | 'form'
- `diff_level` 'word' | 'character'
- `page_image_scale` number
- `show_moves` 'true' | 'false'
- `compare_font_family` 'true' | 'false'
- `compare_font_size` 'true' | 'false'
- `compare_font_color` 'true' | 'false'
- `compare_regular_images` 'true' | 'false'
- `compare_vector_graphics` 'true' | 'false'
- `compare_form_xobjects` 'true' | 'false'
- `compare_shading_objects` 'true' | 'false'
- `pdf_layout` 'split-view' | 'alternating' | 'left-document' | 'right-document'

## Headers

- `Diffchecker-Version` '1'

## Request body

- object
  - `left_pdf` string, required: Data URL of the left PDF (data:application/pdf;base64,...).
  - `right_pdf` string, required: Data URL of the right PDF (data:application/pdf;base64,...).

## Response `200`

Rich-text diff computed successfully.

- union
  - RichTextJsonResponse
    - `creditsUsed` integer, required: Credits charged for the diff request.
    - `diff` RichTextDiffPayload, required
      - `left` RichTextChunk[], required
        - `id` integer, required
        - `type` 'equal' | 'insert' | 'remove' | 'move', required
        - `pageIndex` integer, required
        - `text` string[]
        - `polygons` RichTextPolygon[], required
          - RichTextPoint[]: Polygon outline made of RichTextPoint items.
            - number[]: A single polygon point in PDF coordinate space as [x, y].
        - `moveSegments` RichTextMoveSegments
          - `type` 'remove' | 'insert'
          - `polygons` RichTextPolygon[]
            - RichTextPoint[]: Polygon outline made of RichTextPoint items.
              - …
        - `fontFamilyChanged` boolean
        - `fontSizeChanged` boolean
        - `colorChanged` boolean
        - `image` object
          - `hash` string: Content hash of the `imageUrl` pixels, prefixed with the object type. Equal hashes mean identical images.
          - `objectType` 'image' | 'vector' | 'form' | 'shading'
          - `imageUrl` string: Base64-encoded PNG data URL. For `image` objects this is usually the image's own pixels from the PDF, at `page_image_scale` pixels per point and cropped to its visible part. When that isn't possible (for example, with unusual clipping or transparency), it's the rendered page within `bounds`, as for other object types.
          - `width` number: Pixel width of `imageUrl`.
          - `height` number: Pixel height of `imageUrl`.
          - `byteSize` number
          - `bounds` object: Page-space box of the object. For `image` objects, the part its clip leaves visible.
            - `left` number
            - `top` number
            - `right` number
            - `bottom` number
      - `right` RichTextChunk[], required
        - `id` integer, required
        - `type` 'equal' | 'insert' | 'remove' | 'move', required
        - `pageIndex` integer, required
        - `text` string[]
        - `polygons` RichTextPolygon[], required
          - RichTextPoint[]: Polygon outline made of RichTextPoint items.
            - number[]: A single polygon point in PDF coordinate space as [x, y].
        - `moveSegments` RichTextMoveSegments
          - `type` 'remove' | 'insert'
          - `polygons` RichTextPolygon[]
            - RichTextPoint[]: Polygon outline made of RichTextPoint items.
              - …
        - `fontFamilyChanged` boolean
        - `fontSizeChanged` boolean
        - `colorChanged` boolean
        - `image` object
          - `hash` string: Content hash of the `imageUrl` pixels, prefixed with the object type. Equal hashes mean identical images.
          - `objectType` 'image' | 'vector' | 'form' | 'shading'
          - `imageUrl` string: Base64-encoded PNG data URL. For `image` objects this is usually the image's own pixels from the PDF, at `page_image_scale` pixels per point and cropped to its visible part. When that isn't possible (for example, with unusual clipping or transparency), it's the rendered page within `bounds`, as for other object types.
          - `width` number: Pixel width of `imageUrl`.
          - `height` number: Pixel height of `imageUrl`.
          - `byteSize` number
          - `bounds` object: Page-space box of the object. For `image` objects, the part its clip leaves visible.
            - `left` number
            - `top` number
            - `right` number
            - `bottom` number
      - `changeLog` union[], required
        - union
          - RichTextChangeLogItem
            - `chunkId` integer
            - `contentBefore` string: For a `replace`, the text, or for `visual` content a PNG data URL, before the change. When only one side of a `visual` replacement has the image's own pixels, `contentBefore` and `contentAfter` are both the rendered page within `bounds`, which is how the two were compared.
            - `contentAfter` string: For a `replace`, the text or PNG data URL after the change. See `contentBefore`.
            - `contentType` 'text' | 'visual'
            - `type` 'insert' | 'remove' | 'replace' | 'move' | 'style'
            - `pageIndex` integer
          - RichTextStyleChange
            - `chunkId` integer
            - `text` string
            - `type` 'style'
            - `chunkBefore` RichTextChunk: Represents a single diff chunk. Text chunks include `text`. Visual chunks can include `image` metadata. Equal text chunks can expose style flags.
              - …
            - `chunkAfter` RichTextChunk: Represents a single diff chunk. Text chunks include `text`. Visual chunks can include `image` metadata. Equal text chunks can expose style flags.
              - …
    - `left` RichTextPageInfo, required
      - `pageCount` integer, required
      - `pageDimensions` RichTextPageDimensions[], required
        - `width` number, required
        - `height` number, required
      - `rotations` integer[], required: Per-page /Rotate as PDFium quarter turns. 0=0°, 1=90°, 2=180°, 3=270°.
      - `pageImages` string[]
      - `pageImageScale` number, required
    - `right` RichTextPageInfo, required
      - `pageCount` integer, required
      - `pageDimensions` RichTextPageDimensions[], required
        - `width` number, required
        - `height` number, required
      - `rotations` integer[], required: Per-page /Rotate as PDFium quarter turns. 0=0°, 1=90°, 2=180°, 3=270°.
      - `pageImages` string[]
      - `pageImageScale` number, required
  - HtmlJsonResponse
    - `creditsUsed` integer, required: Credits charged for the diff request.
    - `html` string, required: HTML markup of the diff table.
    - `css` string, required: CSS styles for the diff table.

## Other responses

- `400`: Validation error, malformed or password-protected PDF, or invalid page scale request.
- `401`: Authentication failed. Provide a valid email or API key. Depending on the failure, the response can include more specific error codes.
- `404`: No endpoint matches the request path.
- `405`: The endpoint exists but does not support the request method. The `Allow` response header lists the methods it does support.
- `408`: Request timed out.
- `413`: The request exceeded the active size limit for the caller's authentication method or plan.
- `415`: The request Content-Type is not one this endpoint accepts. `/text` accepts only application/json; the upload endpoints accept application/json and multipart/form-data.
- `429`: Rate limit exceeded. Depending on the throttle, the response may also include `retryAfterSeconds` and a `Retry-After` response header.
- `500`: Unexpected PDF processing failure, or an unexpected server failure.

---

[API](https://skmtc.dev/diffchecker/apis/diffchecker-api.md) · [All operations](https://skmtc.dev/diffchecker/apis/diffchecker-api/llms.txt) · [OpenAPI document](https://skmtc.dev/diffchecker/apis/diffchecker-api/revisions/f2bb895fe9a7?raw)
