Search code examples
javaangularjsspring-mvcdocx4j

convert AngularJS to word document


I have in my disposal a Spring MVC backed server, using AngularJS in client side to display dynamic content. Was researching possibility to get current content displayed in the browser and convert it to a word document.
I assume there's a way to do build word documents with Java, but to do so i'll have to send existing HTML to the server side - how would i do that? just send the document DOM object?
Suppose i'll be able to do so, what if i want to include 2 images? I do know its possible to send images as base64 string.
To conclude, my general approach would be to try and send all client side data to the server and use Java to generate word document.
I have found docx4j so this approach seems possible.

Is that the right way to go? Any thoughts would be appriciated.


Solution

  • On the server side, you can use a library like Apache POI for creating docx documents.

    There are multiple ways to pass data from client to server:

    On the client side, there are some JS libraries available for creating docx documents: