Thursday, May 17, 2012

Xaml vs Docx–vb.net with Richtextbox and WPF

This week I was trying to create a small text editor, actually behind the scenes it is a notebook sort of a thing, but for this blog, it is a editor.  I tried with the WPF RichTextBox Editor, lets say that the control has to improve a great lot to make it easier and more flexible for programmer to work on but to the current extend for my program it is sufficient.  The TextRange class or object plays a major role in this, when saving the data, we need to use it this way:

Dim txtrange As New TextRange(mainRTB.Document.ContentStart, mainRTB.Document.ContentEnd)

Where MainRtb is my RichTextBox, the text range has the save function rather than the Rtb,  with this save feature there are many options like serialization, text, tiff etc and the one I choose is XamlPackage which is a merge of xaml format with zip compression, it is good.

I tested the file size by copy 162 pages of pure text from word to this format and the size is great difference, docx took 116KB were as xaml took only 19Kb, but even if there is a single image docx would have a upper hand.  I think looking into xaml compression for images would be a great improvement for future file handling.

No comments:

Post a Comment