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

4 posts, 0 answers
  1. Kushagra
    Kushagra avatar
    16 posts
    Member since:
    May 2011

    Posted 12 Mar 2014 Link to this post

    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
  2. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 14 Mar 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kushagra
    Kushagra avatar
    16 posts
    Member since:
    May 2011

    Posted 16 Mar 2014 Link to this post

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

    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






  5. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 19 Mar 2014 Link to this post

    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.

     
Back to Top