2

I want to create some simple documents (basically text, footer, maybe some titles, etc) programatically.

The problem is that I am not using .NET. I am in iOS so I cannot use the official SDK

Is there any library in C, C++, or maybe Obj-C that could help? I know that *.docx is XML so I should be able to write it myself but I would rather not re-invent the wheel if there is something handy out there.

Bart
  • 19,692
  • 7
  • 68
  • 77
nacho4d
  • 43,720
  • 45
  • 157
  • 240
  • 2
    Take a look at: http://stackoverflow.com/questions/145573/creating-opening-and-printing-a-word-file-from-c – Adriano Repetti Mar 06 '12 at 11:26
  • 3
    and.. http://stackoverflow.com/questions/8835152/how-to-create-doc-file-or-word-processor-in-ios-application – moritz Mar 06 '12 at 11:42
  • .docX .xmlX are actually a zip archive, not a XML file. – Nyx0uf Mar 06 '12 at 11:45
  • 1
    @Nyx0uf, a .docx is both - a collection of XML and image files wrapped up in a ZIP. – Mark Ransom Mar 06 '12 at 17:02
  • @moritz if you put your comment as an answer I will make you the winner :) Apparently libOPC is what I am looking for. – nacho4d Mar 08 '12 at 16:33
  • it's still just a comment, you're welcome though :-) – moritz Mar 08 '12 at 20:33
  • @nacho4d: With your permission, I can post an answer with due attributions (moritz's comment and jason answer post), of course the best option is that you answer and accept your own question: Your post is a resolved question. – menjaraz Mar 22 '12 at 15:07

3 Answers3

1
  1. Perhaps you should consider exporting to RTF-format. MS Word (all versions) can read RTF-files. Maybe it will be enough for your purposes.
  2. doc-files actually are docfiles (structured storage files) with unopened structure. I do not familiar with iOS, but in windows with installed Word you can use API, that Word provides, to generate documents.
  3. docx-files are zipped set of files and folders. They have a public OpenXML format. It is possible to read the specification of OpenXML or use one of free libraries to generate the required document. However, it looks that you don't need to do it for your purposes. As I understand it, the structure of your document is known in advance. So, you can create a sample of your document. Then unzip created docx-file. Locate where the text of your document stored. Try to change text and then zip files and folder to other docx-file. If you did everything correctly you get a new file with your new text. Therefore, you will know how to programmatically generate desired documents.
Oleg Svechkarenko
  • 2,508
  • 25
  • 30
0

If it's ok for your app to use a service over the net, then a cloud service like that provided by Docmosis will produce doc files based on templates that you upload separately. They can be streamed back to your app, emailed off etc. This approach can save you a lot of dev time but it's not a free service. I don't think it does docX, but it does pdf, odt and some other formats.

Paul Jowett
  • 6,513
  • 2
  • 24
  • 19
0

Thanks to @moritz (in the comments) I found this question that suggest libopc which is what I was looking for. How to create .doc file or word processor in iOS application?

Community
  • 1
  • 1
nacho4d
  • 43,720
  • 45
  • 157
  • 240