Pdfcomparer - PdfComparer
30 Sep 20264 minutes to read
The PdfComparer component provides advanced side-by-side PDF document comparison
with semantic text analysis and interactive difference visualization. It enables users
to identify, review, and navigate content changes between two PDF documents through a
synchronized viewing experience.
Properties
comparisonOptions TextComparisonOptions
Configures semantic text comparison settings, including highlight colors, opacity values, and difference rendering behavior.
Defaults to null
enableDifferencePanel boolean
Determines whether the interactive difference panel is displayed.
When enabled, users can quickly navigate detected differences.
Defaults to true
enablePersistence boolean
Enable or disable persisting component’s state between page reloads.
Defaults to false
enableRtl boolean
Enable or disable rendering component in right to left direction.
Defaults to false
enableSyncScrolling boolean
Determines whether scrolling, zooming, and navigation actions are synchronized between both PDF viewers.
Defaults to true
height string|number
Defines the scrollable height of the PdfComparer control.
Defaults to ‘100%’
locale string
Specifies the culture and localization settings for the PdfComparer component.
Overrides the globally configured culture value.
Defaults to ’’
modifiedDocumentPath string
Specifies the file path, URL, or document source of the modified PDF document
displayed in the right comparison viewer.
Defaults to ’’
originalDocumentPath string
Specifies the file path, URL, or document source of the original PDF document
displayed in the left comparison viewer.
Defaults to ’’
resourceUrl string
Set the resource URL for assets or the public directory. The PdfComparer will load its custom resources from this URL.
Defaults to ’’
width string|number
Defines the scrollable width of the PdfComparer control.
Defaults to ‘100%’
Methods
addEventListener
Adds the handler to the given event listener.
| Parameter | Type | Description |
|---|---|---|
| eventName | string |
A String that specifies the name of the event |
| handler | Function |
Specifies the call to run when the event occurs. |
Returns void
appendTo
Appends the control within the given HTML element
| Parameter | Type | Description |
|---|---|---|
| selector (optional) |
string | HTMLElement
|
Target element where control needs to be appended |
Returns void
compare
Performs semantic text comparison on the currently loaded PDF documents.
Use this overload when both documents have already been loaded through
component initialization or a previous compare operation. The comparison
results are displayed in the difference panel and highlighted within the
synchronized PDF viewers.
Returns Promise
compare
Loads the specified documents and performs semantic text comparison.
This overload allows documents to be provided dynamically at runtime.
Documents can be supplied as file URLs, Base64 document paths, or
Uint8Array byte data. Once loaded, the comparison is executed and the
results are rendered in both viewers and the difference panel.
| Parameter | Type | Description |
|---|---|---|
| originalDocument |
string | Uint8Array
|
Specifies the original PDF document to compare. |
| modifiedDocument |
string | Uint8Array
|
Specifies the modified PDF document to compare. |
Returns Promise
dataBind
When invoked, applies the pending property changes immediately to the component.
Returns void
destroy
Releases all resources used by the PdfComparer component and removes it from the DOM.
Use this method when the component is no longer required to ensure proper cleanup
and prevent memory leaks. This method destroys all internal viewer instances,
removes event listeners, clears generated UI elements, and resets component state.
Returns void
getRootElement
Returns the route element of the component
Returns HTMLElement
refresh
Applies all the pending property changes and render the component again.
Returns void
removeEventListener
Removes the handler from the given event listener.
| Parameter | Type | Description |
|---|---|---|
| eventName | string |
A String that specifies the name of the event to remove |
| handler | Function |
Specifies the function to remove |
Returns void
Inject
Dynamically injects the required modules to the component.
| Parameter | Type | Description |
|---|---|---|
| moduleList | Function[] |
? |
Returns void