POST/pdf/richtext

Compare Documents (Rich Text)

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.

Parameters

emailquerystring

Your email address. Required if not using an API key.

output_typequerystringrequired

Specifies the response format. - `json`: Structured rich-text payload with polygons + page metadata (Content-Type: application/json) - `html`: Self-contained HTML (Content-Type: text/html) - `html_json`: HTML/CSS parts in JSON (Content-Type: application/json) - `pdf`: Binary PDF export with rich-text highlights (Content-Type: application/pdf)

Values: json, html, html_json, pdf

input_typequerystring

Specifies the request content-type. - `form`: multipart/form-data (default) - `json`: application/json

Values: json, form

Default: form

diff_levelquerystring

Specifies whether to diff by word or character. Default is `word`.

Values: word, character

Default: word

page_image_scalequerynumber

Rendering scale used for page image generation and geometry alignment. Allowed range is 0.25 to 4. For non-pdf outputs, explicit values above a document-safe runtime maximum return 400.

Default: 1

show_movesquerystring

Include move detection in the diff. Default is `true`.

Values: true, false

Default: true

compare_font_familyquerystring

Compare font family style changes. Default is `false`.

Values: true, false

Default: false

compare_font_sizequerystring

Compare font size style changes. Default is `false`.

Values: true, false

Default: false

compare_font_colorquerystring

Compare text color style changes. Default is `false`.

Values: true, false

Default: false

compare_regular_imagesquerystring

Compare raster image changes. Default is `false`.

Values: true, false

Default: false

compare_vector_graphicsquerystring

Compare vector graphic changes. Default is `false`.

Values: true, false

Default: false

compare_form_xobjectsquerystring

Compare form XObject changes. Default is `false`.

Values: true, false

Default: false

compare_shading_objectsquerystring

Compare shading object changes. Default is `false`.

Values: true, false

Default: false

pdf_layoutquerystring

Layout used when `output_type=pdf`. - `split-view` (default) - `alternating` - `left-document` - `right-document`

Values: split-view, alternating, left-document, right-document

Default: split-view

Request Bodyrequired

left_pdfstring (binary)required

Left PDF file you want to diff. File extension must be .pdf.

right_pdfstring (binary)required

Right PDF file you want to diff. File extension must be .pdf.

Responses

Every response includes the X-Credits-Used header. In JSON responses, the same value is also available in the creditsUsed field.

Rich-text diff computed successfully.

application/json

One of:

creditsUsedintegerrequired

Credits charged for the diff request.

diffobjectrequired
leftobject[]required
idintegerrequired
typestringrequired

Enum: equal, insert, remove, move

pageIndexintegerrequired
textstring[]
polygonsobject[][]required
moveSegmentsobject
typestring

Enum: remove, insert

polygonsobject[]
fontFamilyChangedboolean
fontSizeChangedboolean
colorChangedboolean
imageobject
hashstring
objectTypestring

Enum: image, vector, form, shading

dataUrlstring

Base64-encoded image data URL.

widthnumber
heightnumber
byteSizenumber
boundsobject
leftnumber
topnumber
rightnumber
bottomnumber
rightobject[]required
idintegerrequired
typestringrequired

Enum: equal, insert, remove, move

pageIndexintegerrequired
textstring[]
polygonsobject[][]required
moveSegmentsobject
typestring

Enum: remove, insert

polygonsobject[]
fontFamilyChangedboolean
fontSizeChangedboolean
colorChangedboolean
imageobject
hashstring
objectTypestring

Enum: image, vector, form, shading

dataUrlstring

Base64-encoded image data URL.

widthnumber
heightnumber
byteSizenumber
boundsobject
leftnumber
topnumber
rightnumber
bottomnumber
changeLogobject[]required
leftobjectrequired
pageCountintegerrequired
pageDimensionsobject[]required
widthnumberrequired
heightnumberrequired
rotationsinteger[]required
pageImagesstring[]
pageImageScalenumberrequired
rightobjectrequired
pageCountintegerrequired
pageDimensionsobject[]required
widthnumberrequired
heightnumberrequired
rotationsinteger[]required
pageImagesstring[]
pageImageScalenumberrequired
creditsUsedintegerrequired

Credits charged for the diff request.

htmlstringrequired

HTML markup of the diff table.

cssstringrequired

CSS styles for the diff table.

Example: output_type=json
{
  "creditsUsed": 1,
  "diff": {
    "left": [
      {
        "id": 0,
        "type": "remove",
        "pageIndex": 0,
        "text": [
          "Left"
        ],
        "polygons": [
          [
            [
              72,
              720.64
            ],
            [
              72,
              706.03
            ],
            [
              90.33,
              706.03
            ],
            [
              90.33,
              720.64
            ]
          ]
        ]
      }
    ],
    "right": [
      {
        "id": 0,
        "type": "insert",
        "pageIndex": 0,
        "text": [
          "Right"
        ],
        "polygons": [
          [
            [
              72,
              720.64
            ],
            [
              72,
              706.03
            ],
            [
              97.65,
              706.03
            ],
            [
              97.65,
              720.64
            ]
          ]
        ]
      }
    ],
    "changeLog": [
      {
        "chunkId": 0,
        "contentBefore": "Left",
        "contentAfter": "Right",
        "contentType": "text",
        "type": "replace",
        "pageIndex": 0
      }
    ]
  },
  "left": {
    "pageCount": 1,
    "pageDimensions": [
      {
        "width": 612,
        "height": 792
      }
    ],
    "rotations": [
      0
    ],
    "pageImages": [
      "data:image/png;base64,..."
    ],
    "pageImageScale": 1
  },
  "right": {
    "pageCount": 1,
    "pageDimensions": [
      {
        "width": 612,
        "height": 792
      }
    ],
    "rotations": [
      0
    ],
    "pageImages": [
      "data:image/png;base64,..."
    ],
    "pageImageScale": 1
  }
}
Example: output_type=html_json
{
  "creditsUsed": 1,
  "html": "<div class=\"rich-text-layout\">...</div>",
  "css": "body { ... }"
}

text/html

string

application/pdf

string (binary)

Example Request

curl
curl -X POST \
  "https://web.preview.diffchecker.com/api/public//pdf/richtext?email=your%40email.com&output_type=json&input_type=json&diff_level=word&page_image_scale=1&show_moves=true&compare_font_family=false&compare_font_size=false&compare_font_color=false&compare_regular_images=false&compare_vector_graphics=false&compare_form_xobjects=false&compare_shading_objects=false&pdf_layout=split-view" \
  -H "Content-Type: application/json" \
  -d '{
  "left_pdf": "data:application/pdf;base64,...",
  "right_pdf": "data:application/pdf;base64,..."
}'

Try It

Understanding the JSON Output

When output_type=json, the response includes polygon overlays and page metadata for both documents. This output is useful for custom viewers, rendering overlays, and downstream automation.

diff.left and diff.right

{
  "diff": {
    "left": [
      {
        "id": 0,
        "type": "remove",
        "pageIndex": 0,
        "text": [
          "Left"
        ],
        "polygons": [
          [
            [
              72,
              720.64
            ],
            [
              72,
              706.03
            ],
            [
              90.33,
              706.03
            ],
            [
              90.33,
              720.64
            ]
          ]
        ]
      }
    ],
    "right": [
      {
        "id": 0,
        "type": "insert",
        "pageIndex": 0,
        "text": [
          "Right"
        ],
        "polygons": [
          [
            [
              72,
              720.64
            ],
            [
              72,
              706.03
            ],
            [
              97.65,
              706.03
            ],
            [
              97.65,
              720.64
            ]
          ]
        ]
      }
    ]
  }
}

The left and right arrays contain chunk-level changes for each document side.

typeDiff classification for the chunk (insert, remove, move, or equal).
pageIndexZero-based page index where this chunk appears.
polygonsPolygon coordinates in PDF space that bound the changed region.
textText lines for text chunks. Visual chunks use visual object metadata instead.

diff.changeLog

{
  "changeLog": [
    {
      "chunkId": 0,
      "contentBefore": "Left",
      "contentAfter": "Right",
      "contentType": "text",
      "type": "replace",
      "pageIndex": 0
    }
  ]
}

changeLog is a linear summary of detected changes.

typeChange kind such as replace, insert, remove, move, or style.
contentTypeIndicates whether a change is text or visual content.
contentBefore / contentAfterHuman-readable before and after values when available.

left and right metadata

{
  "left": {
    "pageCount": 1,
    "pageDimensions": [
      {
        "width": 612,
        "height": 792
      }
    ],
    "rotations": [
      0
    ],
    "pageImages": [
      "data:image/png;base64,..."
    ],
    "pageImageScale": 1
  },
  "right": {
    "pageCount": 1,
    "pageDimensions": [
      {
        "width": 612,
        "height": 792
      }
    ],
    "rotations": [
      0
    ],
    "pageImages": [
      "data:image/png;base64,..."
    ],
    "pageImageScale": 1
  }
}

Both sides include page-level rendering metadata used to align overlays and exported views.

pageDimensionsWidth and height for each page, already scaled for rendering.
rotationsPage rotation values used for coordinate mapping.
pageImagesData URLs for rendered page backgrounds (omitted for PDF export output).
pageImageScaleEffective render scale used after runtime safety checks.