4 Answers, 1 is accepted
In case it's of any use: We use both OpenXML and Telerik on the same document in some of our code. The way we work that is:
- load the file to a byte array (DocxFormatProvider.Import(byte)
- load that byte array into the Telerik objects
- Do what we need to do,
- Export it back to a byte array (DocxFormatProvider Export(RadFlowDocument))
- Load it into the OpenXML objects
- Do our OpenXML actions
WordsProcessing is a library intended to import, modify, generate and export various flow document formats, including DOCX. A file is basically a collection of XML files in accordance with the Office Open XML specification, so I'm not entirely sure what you are trying to achieve, Brian.
If you're looking to edit a document, then the approach Tom outlined is the way to go. You could import a document with the DocxFormatProvider, edit its contents with a RadFlowDocumentEditor and export it back with the format provider.
Alternatively, if for some reason you are looking for access to the underlying XML files, our ZipLibrary can help achieve this task.
I hope this helps, but if I misunderstood your question, please let me know.
I am working on some legacy code that parses (read only) the XML document for various reasons. I am trying to replace a lot of that old code with similar functionality from the Telerik tools. As I do this, I am prioritizing by the amount of time each piece will take me to finish. In this case, it will take a while, so it is going on the back burner. At the same time, if I can swap out some small part of the code with Telerik's equivalent utilities, it will make things easier when I come back to it. So what I am looking for is direct access to read the XML document in the DOCX file.
You mentioned the Zip Library. I looked at that, but didn't see examples dealing with OpenXML documents. Do you know of any such examples?
Thanks for elaborating.
The ZipLibrary can help you gain access to the underlying XML files in a DOCX archive, for example:
In this scenario, you can then read the XML files with File.Open, however, the ZipLibrary doesn't have the capabilities to parse those XML files. This would be something WordsProcessing can handle (to provide some additional context - by using the same ZipLibrary internally) with the approach outlined in the previous posts.
Let me know if I can help with anything else.