Xamarin iOS

Apr 28, 2016 at 2:17 PM

I am trying to get DocX working on iOS with Xamarin.iOS SDK.

As you may or may not know, Xamarin.iOS is a way of developing apps in C# and .NET for, iPhone and iPad. They use (parts of) Mono as opensource replacement for the .Net SDK.

Xamarin.iOS is missing some basic .NET implementations that are required by DocX:
  1. System.Drawing.ColorTranslator.FromHtml
  2. System.Drawing.FontFamily
  3. System.Drawing.Image
  4. System.IO.Packaging
The first 3 are fairly easy to write replacements for, their use in DocX is limited.

System.IO.Packaging proved much more difficult. This is entirely missing from Xamarin.iOS.

I have used downloads from Mono and even reference source of .NET (4.6) to add all System.IO.Packaging code to my project. System.IO.Packaging relies on System.IO.Compression, and that is available in the Xamarin.iOS SDK. I even get to to point where my project compiles without errors. But I cannot get it to run on Simulator or Device due to exceptions. Without going into much detail, it all boils down to the fact that System.IO.Packaging behaves differently than what DocX expects, or that System.IO.Compression behaves differently than what System.IO.Packaging expects.

My questions:

Has anyone tried to get DocX working on an iPad or iPhone (or Android) with via the Xamarin route? And has insights to share?

Can DocX somehow be decoupled from System.IO.Packaging ? Are there replacement implementations for the packaging code?

In the mean time I have written dummy classes for all the missing parts that DocX requires in System.IO.Packaging, now I am trying to fill in the empty parts. But I hate to rewrite all that code.

Anyone out there who solved this problem?

Thank you

Apr 28, 2016 at 4:30 PM
Hi all,

Well, usually a short time after posting a question online I find a solution on my own.

I found the following GitHub repository:


That repository contains an implementation of System.IO.Packaging. I added that code, plus the ZipStorer.cs file. Changed a few namespaces. Fixed a few bugs .. et voila: DocX is running on iOS producing Word documents.

I haven't tested it much, so maybe there are bugs still to solve, but I got the basics working.

One issue I found was, a message from Word when opening the document on a Mac (haven't tried Windows).
Word complains that the contents of the file are corrupt and it cannot be opened. Word then suggests to recover the contents. When it does, the file opens correctly and the content appears to be correct.

Are there tools to verify the validity of.docx files?


Apr 28, 2016 at 4:35 PM
I used :


to validate the file, but this online tool returned a blank page ...
Apr 28, 2016 at 4:43 PM
Here is the document produced by DocX on iOS:


Can someone with more knowledge about docx files shed a light on what it wrong with it?