My requirement was very simple and straightforward (and probably the most common) - read an entire .docx document bytes and send it across to the server for further processing.
I was expecting this to be a simple job with Office.js however, it turned out to be very time consuming and error prone. Hence, thought of sharing this with the community looking for a similar solution. Note - I am using Angular 7 with Office.js library to create a word-add in.
Firstly, the example code provided by Microsoft is not something I was looking at; it sends individual slices to the server which puts responsibility on the server to collect all the chunks and assemble the document. I need to do this entirely on the client end and then send the final base64 encoded string.
I thought of using a iterative approach (I didn't feel any compelling need of using the recursive one) to read all slices of the document, get a base64 encoded string of the document and then process the complete document as a whole (may be sent it to server for further processing).
You can find the entire code here on GitHub.
Comments