/pdf/richtextCompare 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
emailquerystringYour email address. Required if not using an API key.
output_typequerystringrequiredSpecifies 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_typequerystringSpecifies the request content-type. - `form`: multipart/form-data (default) - `json`: application/json
Values: json, form
Default: form
diff_levelquerystringSpecifies whether to diff by word or character. Default is `word`.
Values: word, character
Default: word
page_image_scalequerynumberRendering 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_movesquerystringInclude move detection in the diff. Default is `true`.
Values: true, false
Default: true
compare_font_familyquerystringCompare font family style changes. Default is `false`.
Values: true, false
Default: false
compare_font_sizequerystringCompare font size style changes. Default is `false`.
Values: true, false
Default: false
compare_font_colorquerystringCompare text color style changes. Default is `false`.
Values: true, false
Default: false
compare_regular_imagesquerystringCompare raster image changes. Default is `false`.
Values: true, false
Default: false
compare_vector_graphicsquerystringCompare vector graphic changes. Default is `false`.
Values: true, false
Default: false
compare_form_xobjectsquerystringCompare form XObject changes. Default is `false`.
Values: true, false
Default: false
compare_shading_objectsquerystringCompare shading object changes. Default is `false`.
Values: true, false
Default: false
pdf_layoutquerystringLayout 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)requiredLeft PDF file you want to diff. File extension must be .pdf.
right_pdfstring (binary)requiredRight 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:
creditsUsedintegerrequiredCredits charged for the diff request.
diffobjectrequiredleftobject[]requiredidintegerrequiredtypestringrequiredEnum: equal, insert, remove, move
pageIndexintegerrequiredtextstring[]polygonsobject[][]requiredmoveSegmentsobjecttypestringEnum: remove, insert
polygonsobject[]fontFamilyChangedbooleanfontSizeChangedbooleancolorChangedbooleanimageobjecthashstringobjectTypestringEnum: image, vector, form, shading
dataUrlstringBase64-encoded image data URL.
widthnumberheightnumberbyteSizenumberboundsobjectleftnumbertopnumberrightnumberbottomnumberrightobject[]requiredidintegerrequiredtypestringrequiredEnum: equal, insert, remove, move
pageIndexintegerrequiredtextstring[]polygonsobject[][]requiredmoveSegmentsobjecttypestringEnum: remove, insert
polygonsobject[]fontFamilyChangedbooleanfontSizeChangedbooleancolorChangedbooleanimageobjecthashstringobjectTypestringEnum: image, vector, form, shading
dataUrlstringBase64-encoded image data URL.
widthnumberheightnumberbyteSizenumberboundsobjectleftnumbertopnumberrightnumberbottomnumberchangeLogobject[]requiredleftobjectrequiredpageCountintegerrequiredpageDimensionsobject[]requiredwidthnumberrequiredheightnumberrequiredrotationsinteger[]requiredpageImagesstring[]pageImageScalenumberrequiredrightobjectrequiredpageCountintegerrequiredpageDimensionsobject[]requiredwidthnumberrequiredheightnumberrequiredrotationsinteger[]requiredpageImagesstring[]pageImageScalenumberrequiredcreditsUsedintegerrequiredCredits charged for the diff request.
htmlstringrequiredHTML markup of the diff table.
cssstringrequiredCSS 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
stringapplication/pdf
string (binary)Example Request
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
Click or drag to upload
Click or drag to upload
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.