We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

A corrupted file when i insert a DOCPROPERTU in the footer of the section


i have a corrupted DOCX file when i insert a DOCPROPERTY COMMENTS in the footer of the section with this code:

Document doc = new Document(fileStream1);

DocumentBuilder builder = new DocumentBuilder(doc);

foreach (Section sec in doc.Sections)




builder.InsertField("DOCPROPERTY COMMENTS");


builder.InsertField("DOCPROPERTY COMMENTS");




doc.Save(fileStream1, SaveFormat.Docx);



<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Could you please also attach your input and output documents here for testing? I will check them and provide you more information.

Best regards.

thank you for you post.

do you find in the input and output files


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. The problem occurs because you save the document into the stream, which already contains the original document. When you open document from stream, Aspose.Words reads the stream to the end, so after reading position of the stream is at the end of the stream. When you save document to stream Aspose.Words writes document’s content into the stream starting from the current position. So your output stream actually contains both input and output documents.

The solution is very simple, just save the document into another stream.

Best regards.