I am trying to convert a word .docx document a user is about to upload, to PDF format on the frontend before sending it to the backend. For some reasons, the backend only allows .PDF files. I have seen a couple npm modules like docx-pdf which works by targeting a local path where the document is saved and writes the generated PDF to a specified path. But in this case, we don't have the file in any local directory yet. The only thing we have when a user selects a file is the binary form of the file which is stored in the React state. Is there a way to convert the binary docx document in the React state to PDF before sending to the backend?
And if that wouldn't be possible, how can I save the selected .docx file(which is a binary file) to a directory on the frontend, then convert to PDF before sending to the backend.
Thanks.