In This Topic
Programming / Document Conversion / Converting Microsoft Word Binary File document (.doc) to Microsoft Word OpenXML document (docx)

Converting Microsoft Word Binary File document (.doc) to Microsoft Word OpenXML document (docx)

In This Topic

The GdPicture.NET SDK includes the GdPictureDocumentConverter class, which provides many different methods and properties for document conversion of 100+ document/image formats.

This class also provides methods to manage parameters like font, margin, page range, or image quality.

Now, let’s see how to convert a .doc to a .docx file in two steps:

C#
Copy Code
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.