DOC/DOT: Long Live the King

With the R2 2021 release of our Telerik products, we added the DOC and DOT file formats support (import only) to the RadWordsProcessing library.


This content originally appeared on Telerik Blogs and was authored by Martin Velikov

With the R2 2021 release of our Telerik products, we added the DOC and DOT file formats support (import only) to the RadWordsProcessing library.

What Are DOC and DOT File Formats?

DOC is the Word 97-2003 Binary File Format, developed by Microsoft for saving documents with the .doc extension, and DOT (.dot) is the document template for the same file format.

Now both of them are supported by RadWordsProcessing.

In 2007, with the release of Microsoft Word 2007, the DOC format was replaced by a more open and structured DOCX format (DOT became DOTX), part of Microsoft Office Open XML specification (aka OOXML or OpenXML), but even today both the DOC and DOT formats are still widely used.

DOC/DOТ and RadWordsProcessing

RadWordsProcessing library through its format providers (check Formats and Conversion help article) lets you import different document formats (DOCX, RTF, HTML, Plain text, and now DOC & DOT) into its RadFlowDocument model and export this document data to DOCX, RTF, HTML, Plain text and PDF file format.

Project Setup: Adding New References

In addition to the currently required references, there is a new one responsible for importing DOC and DOT file formats.

There are two approaches you can use to reference the new assembly: via NuGet package or by direct assembly reference.

Reference via NuGet:

.NET Framework:
Telerik.Windows.Documents.Flow.FormatProviders.Doc package

Packages_NetFramework_nuget - Telerik.Windows.Documents.Flow.FormatProviders.Doc

.NET Standard:
Telerik.Documents.Flow.FormatProviders.Doc package

Packages_NetStandard_nuget - Telerik.Documents.Flow.FormatProviders.Doc

.NET Standard for Xamarin:
Telerik.UI.for.Xamarin.Documents.Flow.FormatProviders.Doc package

Packages_NetStandard_Xamarin_nuget - Telerik.UI.for.Xamarin.Documents.Flow.FormatProviders.Doc

Check the NuGet Packages help article for more detailed information on the different NuGet packages related to Telerik Document Processing.

Add assembly reference:

.NET Framework:
Telerik.Windows.Documents.Flow.FormatProviders.Doc.dll

Packages_NetFramework_dll - Telerik.Windows.Documents.Flow.FormatProviders.Doc.dll

.NET Standard:
Telerik.Documents.Flow.FormatProviders.Doc.dll

Packages_NetStandard_dll - Telerik.Documents.Flow.FormatProviders.Doc.dll

Now that the references are added, we’re ready to examine the new format provider class.

Using DocFormatProvider

DocFormatProvider makes it easy to import a DOC or DOT file into a RadFlowDocument, preserving the entire document structure and formatting. You can easily import a RadFlowDocument from DOC or DOT document format in the following manner:

RadFlowDocument document;
string pathToDoc = "SampleFile.doc"; // "SampleFile.dot"
using (Stream inputStream = File.OpenRead(pathToDoc))
{
DocFormatProvider docFormatProvider = new DocFormatProvider();
document = docFormatProvider.Import(inputStream);
}

You can find more information in the Using DocFormatProvider help article.

Once imported, the RadFlowDocument can be exported as a byte array:

DocxFormatProvider provider = new DocxFormatProvider();
byte[] output = provider.Export(document);

or as any of the supported by the RadWordsProcessing document formats (supported formats).

Features

DocFormatProvider supports features like Text Formatting, Paragraph Options, Page/Section options, Tables, Inline Images, Themes, Hyperlinks, Fields, Headers & Footers, and many others that can be found in the Features help topic.

Converting DOC/DOT to DOCX

RadFlowDocument document;
string pathToDoc = "Legacy.doc"; // "Legacy.dot"
string pathToDocx = "Current.docx";
 
using (Stream inputStream = new FileStream(pathToDoc, FileMode.Open))
{
    DocFormatProvider docFormatProvider = new DocFormatProvider();
    document = docFormatProvider.Import(inputStream);
}
 
using (Stream outputStream = new FileStream(pathToDocx, FileMode.OpenOrCreate))
{
    DocxFormatProvider docxFormatProvider = new DocxFormatProvider();
    docxFormatProvider.Export(document, outputStream);
}

Try RadWordsProcessing Yourself

Get yourself a free trial of Telerik Document Processing today and start developing your apps better, faster, and more easily.

Start My Trial

Share Your Feedback

Let’s continue to build the future of Telerik Document Processing together! So, don’t forget to share your thoughts as a comment below or let us know if you have any suggestions and/or need any features/components by visiting our Telerik Document Processing Feedback Portal and Telerik Document Processing Forum.


This content originally appeared on Telerik Blogs and was authored by Martin Velikov


Print Share Comment Cite Upload Translate Updates
APA

Martin Velikov | Sciencx (2021-06-03T13:01:00+00:00) DOC/DOT: Long Live the King. Retrieved from https://www.scien.cx/2021/06/03/doc-dot-long-live-the-king/

MLA
" » DOC/DOT: Long Live the King." Martin Velikov | Sciencx - Thursday June 3, 2021, https://www.scien.cx/2021/06/03/doc-dot-long-live-the-king/
HARVARD
Martin Velikov | Sciencx Thursday June 3, 2021 » DOC/DOT: Long Live the King., viewed ,<https://www.scien.cx/2021/06/03/doc-dot-long-live-the-king/>
VANCOUVER
Martin Velikov | Sciencx - » DOC/DOT: Long Live the King. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/03/doc-dot-long-live-the-king/
CHICAGO
" » DOC/DOT: Long Live the King." Martin Velikov | Sciencx - Accessed . https://www.scien.cx/2021/06/03/doc-dot-long-live-the-king/
IEEE
" » DOC/DOT: Long Live the King." Martin Velikov | Sciencx [Online]. Available: https://www.scien.cx/2021/06/03/doc-dot-long-live-the-king/. [Accessed: ]
rf:citation
» DOC/DOT: Long Live the King | Martin Velikov | Sciencx | https://www.scien.cx/2021/06/03/doc-dot-long-live-the-king/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.