I have an issue where .doc and .pdf files are coming out OK but a .docx file is coming out corrupt.
In order to solve that I am trying to debug why the .docx is corrup
Many years late, but I found this which actually worked for me. (From https://msdn.microsoft.com/en-us/library/office/bb497334.aspx)
(wordDoc is a WordprocessingDocument
)
using DocumentFormat.OpenXml.Validation;
try
{
var validator = new OpenXmlValidator();
var count = 0;
foreach (var error in validator.Validate(wordDoc))
{
count++;
Console.WriteLine("Error " + count);
Console.WriteLine("Description: " + error.Description);
Console.WriteLine("ErrorType: " + error.ErrorType);
Console.WriteLine("Node: " + error.Node);
Console.WriteLine("Path: " + error.Path.XPath);
Console.WriteLine("Part: " + error.Part.Uri);
Console.WriteLine("-------------------------------------------");
}
Console.WriteLine("count={0}", count);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}