Converting a Microsoft Word binary file document (DOC) to a Microsoft Word OpenXML document (DOCX) in C#

Nutrient .NET SDK (formerly GdPicture.NET) includes the GdPictureDocumentConverter class, which provides many different methods and properties for document conversion of 100+ document/image formats. This class also provides methods for managing parameters like font, margin, page range, and image quality. This example shows how to convert a DOC file to a DOCX file in two steps:


GdPictureStatus status;
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
status = gdpictureDocumentConverter.LoadFromFile("input.doc");
if (status == GdPictureStatus.OK)
{
status = gdpictureDocumentConverter.SaveAsDOCX("output.docx");
if (status == GdPictureStatus.OK)
{
System.Windows.MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
System.Windows.MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
System.Windows.MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
/**
Do not forget to use the GdPictureStatus class to have a following of your process and get potential errors.
GdPictureDocumentConverter provides two ways of saving your document as a DOCX:
- as a string, which is the destination file path
- using a Stream object, to write the document data onto.
You can also change properties.
For example, you can change the image quality in your DOCX output document like this:
gdpictureDocumentConverter.DocxImageQuality = 100;
You will find here all the properties here: https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureDocumentConverter_properties.html
*/

This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.