Index ¦ Archives ¦ RSS

Comparing text documents in Collabora Online

Estimated read time: 6 minutes

If you have two documents or two versions of a document to compare, then traditional tracked changes is too late, the untracked changes are already in the document.

This work for Collabora Online adds interactive a non-interactive document compare to create tracked changes after the fact, finally introduces a document compare view, to better understand these changes.

Motivation

Collabora Online's core already contained a document compare feature, but this was never integrated with the SDK (REST API) or with the browser UI.

Additionally, while some users took a training in understanding track changes (or: redlines), the usage of underlines for inserts and strike-throughs for deletions may not be obvious. An alternative of this is a side-by-side view, which is now available in Collabora Online for text documents.

Results so far

Non-interactive document compare

See the SDK, now you can convert e.g. an editable (new) docx file to PDF in a way that your request references your old docx file as a parameter, and the resulting PDF shows the differences:

curl -k -F "data=@new.docx" -F "compare=@old.docx" -F "format=pdf" -o out.pdf https://localhost:9980/cool/convert-to

Interactive document compare

Technically this is a bit similar to image insertion: once you open your new document, you can compare its content with an old local or remote document:

Collabora Online: interactive document compare for text documents

Just use the Compare button on the Review tab on the notebookbar.

Document compare view

We worked with Gokay to build this. The LOK API now provides "tile modes" for text documents, similar to how presentations already have tile modes for slide content, master pages and notes. The default tile mode is unchanged for text documents, but the Review tab of the notebookbar has a View Changes button and then the new left hand side, right hand side tile modes allow you to show the changes side by side:

Collabora Online: the new document compare view

Removed content is colored with a red-like color, added content is colored with a green-like color. The matching content on the other side is gray. This is not only for text, e.g. images have a frame with a similar color.

Now that the LOK API could provide tiles either left or right hand side mode, Gokay built a whole new tile layout on the browser side, so these are shown nicely side by side.

To better understand what you see on your screen, now there are also labels at the top of the first pages:

Collabora Online: the new document compare labels

This describes the purposes of the two sides, and in case you're right after a document compare action, also shows you the file names, modification dates and author names.

For integrators, it's possible to start in this mode by default, if you append &comparechanges=1 to COOL's iframe URL.

Finally if you hover over a tracked change with your mouse, now you get a highlight for that piece of text on both sides, to match the same parts of the old and new version better. A deletion looks like this:

Collabora Online: document compare view, highlight of a delete

This also works for inserts:

Collabora Online: document compare view, highlight of an insert

How is this implemented?

If you would like to know a bit more about how this works, continue reading... :-)

As usual, the high-level problem was addressed by a series of small changes. Core side:

COOL side:

Want to start using this?

You can get a development edition of Collabora Online 25.04 and try it out yourself right now: try the development edition.

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.