SOLVED: Uploading and Converting Files

I have this project I’m working on and I need some help.

I need to upload a MS Word .doc or .docx file, then divide the text into sections. The first 9000 characters go into a collection field and then the next 50000 characters into another collection field. The field data is loaded into an editor where the user can edit it. The edited text goes into another field. When editing is done all the sections are combined into a PDF file.

Where I need help:
I can upload files using an “Upload Button” but .txt is not an option, so I would have to convert .doc or .docx to text in Wix code. No JavaScript way to do it that I know of. No npm module available in Wix to do it. None that I can find anyway. Not sure how long it would take Wix to install one after my request.
So I set up fetch requests in the backend to have an API convert the doc to text. I got this working locally in Node but then I found that Wix doesn’t recognize FileReader(). I think that I would need fileReader to convert the return .txt file to editable text.

Any Ideas?

What API do you use to make the conversion elsewhere? What you will need to do is to post back the converted text elements, preferable as JSON chunks or a large JSON chunk and then use the http-functions and protocol POST to receive that data and insert it into the data collections. Then you will also need some other external tool to make it a PDF but there is a ton of tools that can do that.

I figured it out. On the fetch response I was using .then(res => res.blob()) . That required me to use FileReader() that is not supported. I switched to .then(res => res.text()). That gives me plain text.

1 Like