-
Notifications
You must be signed in to change notification settings - Fork 95
[Research] Preview of DOCX and PPTX in the Documents perspective #5811
Description
Objective
Can we have a preview of .docx and .pptx files in Dirigible.
Background / Context
In the Documents perspective, the user can upload any file.
Most files are easily previews using the built-in previewer but there are some files (like .docx and pptx) that are not yet supported.
Findings
After researching the topic, here are the options we have:
Use Microsoft's or Google's document viewer
-
Requirements:
- File must be publicly accessible via URL
-
Pros:
- Very accurate rendering (same engine as Word)
- No parsing needed
-
Cons:
- Requires internet
- Uploads the file to a MS or Google server which is a security risk for confidential documents
- No control over the UI, so the integration will not be good
Use a JavaScript library
There are several option like docxjs and docx2html
-
Requirements:
- Add the library using a webjar and integrate it into the Document perspective
-
Pros:
- Done on the client-side
- Lightweight
- Small size
-
Cons:
- File must be converted
- Could worsen the UX as the converting is done on the client-side and depending on the device and document, it could take a while to render
- Not every doc element is supported (like shapes, charts, word art, etc)
- The layout may not be 100% the same
Render document server-side
We could use projects like https://github.com/gotenberg/gotenberg or integrate the LibreOffice API directly.
-
Requirements:
- Extend Dirigible deployment option to include Gotenberg's Docker container and create an API to communicate with it
- Integrate a headless LibreOffice into Dirigible
-
Pros:
- Lessens the burden on the client
- More accurate rendering then the client-side JS library
-
Cons:
- File must be converted
- Depending on the document, it can take time to render
- Not guaranteed that the converted document will look exactly like the original
- Possible license issues
Conclusion
The first option is not viable, as it depends on internet access, requires the use of third-party services, and introduces potential security vulnerabilities.
The second option is the simplest to implement and requires minimal effort. However, it may lead to a degraded user experience. Also, discrepancies in how the document is rendered could result in confusion or frustration for users. For these reasons, I cannot recommended this approach.
The third option addresses many of the limitations of the previous two. That said, it may still produce inconsistencies in document rendering and introduces additional complexity and overhead to Dirigible for what is a basic file preview feature. I do not think it's worth the effort, so I do not recommend this one either.
A more suitable approach would be to implement a whitelist for previewable file types. For unsupported files, the system should display a clear “File cannot be previewed” message.