I am creating a word document using a template with Aspose.Words.dll 188.8.131.52. Following are the steps of tasks that I am performing while generating document programmatically:
- Open template file using Aspose api.
- Dynamically create a merge field.
- Save the document.
- Reopen the document using OOXML.
- Create a chart using OOXML because Aspose doesn’t provide editable chart feature in Word.
- Replace the merge field using OOXML.
- Save and close the document.
Now When I open the document from the hard disk, It gives me following error:
‘We’re sorry.We can’t open “Document.docx” because we found a problem with itscontents.’
"Location: Part: /word/header1.xml, line: 1, column: 0"
In my investigation, I have found below few points:
1. The above error occurs when I have text in page header in template and I create a chart as well.
If I don’t create a chart in document, this error doesn’t occur. Or, If I remove page header and create a chart, the error doesn’t occur.
2. When I remove either of the two (ie. page header and chart), it works. There is no error at all while opening the document. The above error occurs when I have both page header and chart in my document.
Note: This error started coming when I updated my Aspose.Words.dll from version 184.108.40.206 with new version 220.127.116.11. It works perfectly when I use Aspose.Words.dll 18.104.22.168.
I have attached my sample project and error.png as well for your reference. Please look into this and help me out.