How can i parse text from docx file?
I already tried Data(contentsOf:) and String(contentsOf:) but nothing worked.
How can i parse text from docx file?
I already tried Data(contentsOf:) and String(contentsOf:) but nothing worked.
This can't be done using Data(contentsOf:) or String(contentsOf:) because .docx format is a zipped format consists of xml and other files. In order to parse the text from the .docx file, you should unzip the doc file. In my case, I used ZIPFoundation to unzip the document. Parse the file named word/document.xml under the extract path using any XML Parser and you will be able to get the text from the document.
Sources: