How to store .docx file to an Entity which contains the file as an attribute in One to One Association and display the file as HTML (convert docx to HTML) for viewing in TextArea Component on Entity Edit Screen
Lets take an entity for example say “Employee”.
Employee has attributes like Name, Age, Years of Experience.
Now I would like the Employee entity to have a “.docx file as an attribute” with ONE TO ONE Association. Lets say for example “BioData”.
Each employee object will have a biodata file (.docx) as attribute.
Also I would like to convert the biodata file to HTML and display it in the TextArea component of the edit screen as read only.
I would like to know on how to achieve this as I am new to this concept.
With the report addon you can achieve something like this. Although feom previous experience i would suggest that you convert it to pdf and use the browser to display it inline. I had very good success with that approach. Perhaps i have the time to come up with anplan example later…
For my project, my entity needs a .docx file as attribute with ONE to ONE association. I would like to display the file as HTML in the entity editor screen as read only with Edit Button.
By clicking on the edit button, I would like to edit the docx file by calling an API to the docx editor web app service (SAAS) like CK Editor to edit the file and save it back in the datasource.
Well, the basic problem is that a moderate styled docx file looks just bad when trying to export it to HTML. This is why PDF is an easy way to achieve 99% pixel perfect preview.
If you really cannot use it, then there are some SaaS options like OnlyOffice (https://www.onlyoffice.com) or Office365 directly where they offer capabilities to preview files (as well as also editing it). See: ONLYOFFICE Api Documentation
Trying to hack something together with CKEditor and docx parsing is just a very painful and not very nice way of achieving the same.
I think you misunderstood my idea. The docx will be stored as 1:1 association. Then you have a preview button next to it, which will preview the file directly in the browser as a popup e.g. to achieve that the cuba app will create a pdf internally on the fly and send it to the browser.
When the user wants to edit, it will take the original docx and send it to your saas provider to edit it. Once the edit is done, the updated docx. Will be re-saved as docx in the cuba app. Next time the preview btn is clicked, the preview will be created based on the new docx.
You can forget about if it is pdf or not. If i got you right, you just want a preview in the browser. This is exactly what it is…
Example for 1:1 association, you directly use an association to cubas FileDescriptor. Everything else (upload etc. Works out of the box).