PDF Comparisons

PDF Comparisons

To invoke a comparison, you POST parameters to the specified PDF Compare pipeline, in either JSON or XML form.

POST request
POST /api/compare/pdf
Content-Type: application/xml

Comparison Example

Here is a simple synchronous example (asynchronous comparison is detailed in more detail on this page):

Request (XML)
XML
<pdf>
  <inputA type="file">
    <path>samples/compare/pdf/invoice_v2_VERSION_A.pdf</path>
  </inputA>
  <inputB type="file">
    <path>samples/compare/pdf/invoice_v2_VERSION_B.pdf</path>
  </inputB>
  <configuration type="file">
    <path>samples/compare/pdf/sample-configuration.xml</path>
  </configuration>
</pdf>
Request (JSON)
JSON
{
  "inputA": {
    "type": "file",
    "path": "samples/compare/pdf/invoice_v2_VERSION_A.pdf"
  },
  "inputB": {
    "type": "file",
    "path": "samples/compare/pdf/invoice_v2_VERSION_B.pdf"
  },
  "configuration": {
    "type": "file",
    "path": "samples/compare/docbook/sample-configuration.xml"
  }
}

The response below indicates the comparison result, in this case a HTML file that will show a side by side view of the compared PDFs.

Response
XML
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>PDF Comparison - invoice_A vs invoice_B </title>
        <style>
          ...

</html

Comparison Model

When specifying a comparison, these are the various available objects:

Object

Description

inputA

(required)

Input A to the comparison.

See this page for the various I/O types available. 

inputB

(required)

Input B to the comparison.

See this page for the various I/O types available. 

configuration

Configuration to the comparison

See this page for more information on configuration files.

See this page for the various I/O types available.

catalog

File path or HTTP URI pointing to catalog file(s).

See this page for the various I/O types available.

async

output

Specification of where the comparison result will be written.

See this page for the various I/O types available. 

callback

URL that will be polled after the comparison is complete.

See Callbacks in Async for more information.

Form Input

In addition to requests in structured XML or JSON format, multipart/form-data can also be used.

For example:

Request
POST /api/compare/pdf
Content-Type: multipart/form-data; boundary=boundary-id
Content-Length: number_of_bytes_in_entire_request_body

--boundary-id
Content-Disposition: file; filename="file1.pdf"
Content-Size: 98344
Content-Type: application/xml

... XML  ...
--boundary-id
Content-Disposition: file; filename="file2.pdf"
Content-Size: 92224
Content-Type: application/xml

... XML  ...
--boundary-id
Content-Disposition: file; filename="configuration.xml"
Content-Size: 32224
Content-Type: application/xml

... XML  ...
--boundary-id

Content-Disposition: form-data; name="async"
true
--boundary-id

The following table describes the parts that can make up the form-data:

Parameter

Description and example usage

inputA (required)

Input A

Can be specified in either a file path or a HTTP URI

inputB (required)

Input B

Can be specified in either a file path or a HTTP URI

configuration

Configuration file

Can be specified in either a file path, a HTTP URI, or raw XML

catalog

File path or HTTP URI pointing to catalog file(s).

async

Whether async comparison is used.

Default value if not specified: false

output

An optional file path to write the output to when using async.

E.g. "/Users/exampleUser/Documents/test.xml"

callback

Callback URL called after comparison is complete.

Note : only used with asynchronous comparisons. See this page.