This is a migrated thread and some comments may be shown as answers.

DocxFormatProvider no longer appears to be an IDocumentFormatProvider

3 Answers 419 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 18 Aug 2014, 03:16 PM
Good morning,
My company is looking at using the RadRichTextBox control for rendered, editing, and exporting Docx documents. I am attempting to write a small test app as a proof-of-concept but I've hit a problem I can't get around. In all of the demos/tutorials I am seeing online they are creating a DoxFormatProvider and using it to create a document like the following:

using( Stream readStream = dialog.OpenFile() )
{
   IDocumentFormatProvider provider = new DocxFormatProvider();
   RadDocument = provider.Import( readStream );
}

Unfortunately what I am seeing is that DocxFormatProvider will not cast to an IDocumentFormatProvider. DocxFormatProvider appears to be a BinaryFormatProviderBase<RadFlowDocument> found in the Telerik.Windows.Documents.Flow assembly. The DocxFormatProvider returns a RadFlowDocument rather than a RadDocument which I have been unable to find a way to get a RadFlowDocument to work in the RadRichTexTextBox control.

It appears like all other providers have their own DLL following the pattern Telerik.Windows.Documents.FormatProviders.XXX.dll where XXX is the provider type but I do not see a Docx DLL. The assemblies I am working with are 2014.2.729.45. Any guidance would be greatly appreciated. Thanks!
Jason

3 Answers, 1 is accepted

Sort by
0
Accepted
Petya
Telerik team
answered on 19 Aug 2014, 04:08 PM
Hello Jason,

Indeed, the Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider class is used to import/export RadFlowDocument instances. The class is related to the functionality of the RadWordsProcessing library and would not work with RadRichTextBox.

In order to create a RadDocument, you need to use the format provider located in the Telerik.Windows.Documents.FormatProviders.OpenXml.dll in the Telerik.Windows.Documents.FormatProviders.OpenXml.Docx namespace. Please note that a reference to the Telerik.Windows.Zip.dll is required as well to ensure the provider works properly.

I hope this helps.

Regards,
Petya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Michael
Top achievements
Rank 1
answered on 17 Feb 2016, 09:27 PM

Even though this is the WPF forum, I have encountered the same problem in a WinForms application.  The error I am getting is that "Value of type 'RadDocument' cannot be converted to 'RadDocument'.  I have attached an image with the code and error.

I tried using the code directly from this page ("http://www.telerik.com/help/winforms/richtexteditor-import-export.html") and simplified it to try to eliminate the error.  No luck.  Any suggestions?

0
Michael
Top achievements
Rank 1
answered on 17 Feb 2016, 10:07 PM
UPDATE:  The issue was apparently caused by the fact that my sample application was using both a RadFlowDocument and RadDocument and VS intellisense was grabbing the wrong library.  It was using Telerik.Windows.Documents.... instead of Telerik.WinForms.Documents....  When I directly referenced the namespaces everything worked.  Hope this helps someone else!
Tags
RichTextBox
Asked by
Jason
Top achievements
Rank 1
Answers by
Petya
Telerik team
Michael
Top achievements
Rank 1
Share this question
or