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

How do I modify editor to open a .dotx template file

3 Answers 65 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Kushagra
Top achievements
Rank 1
Kushagra asked on 12 Mar 2014, 06:45 AM
Hi Support,

I want to modify the behavior of editor to accept .dotx files also. Kindly, let me know the fastest way to achieve it.

Regards,
Kushagra

3 Answers, 1 is accepted

Sort by
0
Missing User
answered on 14 Mar 2014, 05:08 PM
Hi Kushagra,

Thank you for contacting us!

I’m afraid that RadRichTextBox doesn’t have such format provider which you could use to import .dotx templates.

In a nutshell, the fastest way to achieve your desired scenario is to change the extension of the file from .dotx to .docx and the document would be opened. Please be aware that the two formats have very much in common but there might be some differences. 

Alternatively, you could create a custom format provider by inheriting from DocumentFormatProviderBase class. Please note that this task is not a trivial one.

Let me know how it goes. I would be glad to provide any further assistance in case this doesn’t help you.

Regards,
Yancho
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
0
Kushagra
Top achievements
Rank 1
answered on 16 Mar 2014, 06:13 AM
[quote]Alternatively, you could create a custom format provider by inheriting from DocumentFormatProviderBase class. Please note that this task is not a trivial one.[/quote]
Hi Yancho,

Can you please elaborate on how to get .dotx format included if I create custom format provider by inheriting from DocumentFormatProviderBase , what are the methods , I will have to override and how.

Regards,
Kushagra






0
Missing User
answered on 19 Mar 2014, 11:32 AM
Hi Kushagra,

As I noted in my previous reply, the implementation of a custom format provider is not a trivial task.

I could only suggest that if you are going to implement your own format provider you would need to implement IDocumentFormatProvider interface. If you wish the open command to recognize your custom format provider extension (.dotx in your case), you should register it like this:
DocumentFormatProvidersManager.RegisterFormatProvider(new CustomFormatProvider());

Also I would recommend you download the source code of the controls and use the OpenXml format provider as a base point for your custom format provider. The files related to the implementation of DocxFormatProvider are located at ..\Documents\Flow\FormatProviders\OpenXml\Docx.

If you do not want to implement the provider from scratch you could try implementing the interface and using the default DocxFormatProvider in the Import() method of your provider. This would allow you to open files with extension .dotx, but again you should be aware that some discrepancies in the data might be observed.

I hope that this information would be helpful for you.

Regards,
Yancho
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
Tags
RichTextBox
Asked by
Kushagra
Top achievements
Rank 1
Answers by
Missing User
Kushagra
Top achievements
Rank 1
Share this question
or