A proof of concept (JAX-RS 2.0) to show how a web-based HTML rich text editors (eg CkEditor) can be used to edit docx files (via XHTML round trip).
We've published this as a "cheap and cheerful" option only; for a commercial grade solution (new in 2018), please see https://nativedocuments.com/ (which takes a completely different approach).
That said, it should work OK for documents containing text, tables, and images. Exotic Word features are not supported.
Interested docx4j community members are welcome to improve it and offer pull requests.
docx-html-editor is licensed under the AGPLv3. This means you have to publish any changes you make.
How it works
The idea is:
- use docx4j to convert the docx to XHTML
- use CKEditor to edit that XHTML in the web browser
- on submit, convert the XHTML back to docx content
The general problem with converting to/from XHTML is the “impendance mismatch”. That is, losing stuff during round trip. This will be a familiar problem to anyone who has ever edited a docx in Google Docs or LibreOffice.
This demo addresses that problem by identifying docx content which CKEditor would mangle, and then on submit/save, using the original docx content for those bits.
In this demo, the problematic content is replaced with visual placeholders, so you can see it is there.
Pre-reqs: Since we don't distribute a binary, you'll need maven to build from source.
Get CKeditor (v184.108.40.206); unzip it to src/main/webapp/ckeditor (so you have src/main/webapp/ckeditor/ckeditor.js etc)
Build the war:
Load the resulting war file from dir target to your app server (eg Tomcat)
Visit the upload page in your web browser
Set this up as a Maven project (eg in Eclipse) to get the dependencies.