Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading or Converting word .doc files iOS

How are other apps on iOS able to read and write word docs? I see some other questions related to this and accepted answers are along the lines of "it can't be done." I don't want to just display a word doc, I want to read it along with its formatting. How are other apps doing it, are they writing the parsing themselves using the published standard put out by Microsoft? Are they using some kind of bundled utility to convert the file to some other format like XML or HTML before processing it? Is there an open source way of doing this? Looking for ideas.

like image 948
casey Avatar asked Nov 22 '11 17:11

casey


2 Answers

I don't know if you are still looking for solution or you figured it yourself but I am answering this hoping it will help someone else looking for the same.

I was looking for a solution related to my task that I want to convert word file to text file. I came on this question after some googling and according to the answer from @TJD I gone on the link and from there I found this link.

For my requirement as I was needed to convert word file to text file. I followed second link as my solution.

As the docx file is created with Open XML File format and it is mentioned in there I understand that I need to unzip the docx file considering it a zip.

For Zip/Unzip google provides code here. After unziping the docx file in our document directory according to the wikipedia link there are three directories and one xml file in root.

For my solution I choose word directory as mentioned in link that original content of file is placed there (I didn't gone in any other directory or file till now). There is a file under your extract path word/doctment.xml this is where your docx file content placed in xml format.

There are lots of tags available in that xml file and I don't know the meaning of those text right now but after looking at the xml file I got that the tag which contain my text is w:t.

After that every thing is like cake. I just used NSXMLParser and parsed the data from the xml file targeting the w:t tag and I got my whole string.

Note: I will update my answer as soon as I understand about the other files and tags. As well this solution is not working with doc files as of I know OpenXMLFile format is introduced in MSOffice 2007 so I will also update my answer for doc file solution.

I know this is not enough that it is not covering creating doc file etc. But I hope this will help lots of us.

like image 155
Kapil Choubisa Avatar answered Sep 20 '22 11:09

Kapil Choubisa


The "trick" most apps use to read Word files is UIWebView — it can read them. This doesn't allow for writing docs, but that is a much harder problem for which I don't believe an easy solution exists.

like image 29
Chuck Avatar answered Sep 18 '22 11:09

Chuck