Side-by-side PDF comparison matches pages by index, so content pushed onto the next page is reported as deleted and re-inserted

Product: GroupDocs.Comparison for Java 26.9
Platform: Java 21, macOS and Linux (Docker)

Summary
When an edit pushes later content onto the next page, ComparisonDisplayMode.SIDE_BY_SIDE reports the displaced content as deleted on its original page and inserted on the next one, even though its text is unchanged. Side-by-side seems to compare page N of the source with page N of the target, rather than the documents as a whole.

A side effect: the displaced lines are diffed letter by letter against the unrelated inserted lines they are paired with. That produces scattered partial highlights, where single letters inside words are left unmarked.

INLINE mode compares the same files correctly: only the inserted lines are marked. So cross-page matching works in the engine, just not in side-by-side mode.

Steps to reproduce
Attached: old.pdf, new.pdf, Repro.java, and MakeRepro.java, which rebuilds both PDFs using only PDFBox 3.x. Both are laid out 18 lines per Letter page.

  • old.pdf: page 1 has 4 intro lines, 4 lines starting “Curabitur pretium…” and 10 filler lines. Page 2 has 4 tail lines.
  • new.pdf: the same text with 14 lines (“Insertum 1…14”) inserted after the intro. That fills page 1, so everything after it moves to page 2 unchanged.

Repro.java compares them with default PdfCompareOptions, once per display mode.

Expected: in both modes, only the 14 “Insertum” lines are marked as inserted.

Actual (side-by-side), see out-side-by-side-page1.png and -page2.png:

  • Page 1: all 14 displaced lines are marked as deleted, with letter-level fragments.
  • Page 2: the same 14 lines are marked as inserted.

Actual (inline), see out-inline-page1.png and -page2.png:

  • The comparison is correct: only the “Insertum” lines are marked.
  • Page 2 draws the old page-2 lines on top of the displaced lines. This looks related to our inline overprint report.

What we tried in side-by-side mode

  • setDetalisationLevel(LOW | HIGH) and setSensitivityOfComparison(25 | 90): output identical to the default.
  • As a diagnostic, we stacked each document’s pages onto a single tall page before comparing. Then side-by-side was correct as well.

Question
Can side-by-side use the same document-level matching that inline mode uses? Or is there an option we’ve missed that enables it?

groupdocs-pagination-repro.zip (605.0 KB)

hi @ristomattip ,
Thank you for the detailed investigation and for providing the reproduction files.

Yes, you are correct. Currently, in SIDE_BY_SIDE mode, the comparison is performed effectively page by page rather than using document-level matching. This can lead to the behavior you described when content is shifted to another page. We’ll investigate this approach and consider how we can make SIDE_BY_SIDE mode use the same document-level matching as INLINE mode.

Regarding the issue with the INLINE mode, it is related to the same problem described in your other ticket:

This issue is planned to be fixed in an upcoming release, and we will let you know as soon as the fix is available.

Hello @ristomattip,

Thank you for your feedback. I’d like to let you know that all the changes you mentioned will be included in the release scheduled for next week. We’ll post an update in this thread as soon as it’s live.

Thank you for your patience!