Hi,
we are using Aspose Words.NET
to generate some documents. We are having problems with docx files sometimes using the wrong line spacing, leaving us with documents that do not look the way they’re supposed to. We could not figure out why this was happening, we have a base doc template with sections in which we put some other templates (all of them are DOC, not DOCX) and we put a user’s DOC or DOCX file. Most of the DOCX we try to put in cause the whole document to change line spacing, making it look broken. As we couldn’t find a way for this to not happen (the only docx in the whole merge process was put in using ImportNode and adding the node, tried using both KeepSourceFormatting and UseDestinationStyles), we decided we could just always convert the DOCX to a DOC and not have the problem, as DOC never changes the line spacing.
So, we put in this code:
// Load user document from fileStream
Aspose.Words.Document user = new Aspose.Words.Document(userFileStream);
userFileStream = null; // added when didn't work without, but didn't change the result
userFileStream = new MemoryStream();
user.Save(userFileStream, SaveFormat.Doc); // force saving to filestream as DOC
user = null; // same as userFileStream = null;
user = new Aspose.Words.Document(userFileStream); // create new user document from the (what should be) DOC generated from the DOCX
we expected this to work as DOC always works, but it didn’t, so we put in a save to file as doc after this code snippet and realized that the DOC isn’t the same DOC that word generates when saving DOCX to DOC.
This causes our document to have a “broken” look.
Attached are four files:
- Start_docx.docx which is the starting point document(it’ s just a regular docx created in Word 2007)
- Start_doc-saved_through_word.doc which is the DOC that was created by opening Start_docx.docx in Word and pressing Save as and choosing doc instead of docx
- aspose_convert.doc which is the result of the save to file after the conversion using Aspose Words that I mentioned earlier
- aspose_convert-saved_through_word.doc which is the aspose_convert.doc opened in Word and saved to a new DOC file using the same method used to save the Start_doc-saved_through_word.doc file
From the file sizes it looks like the aspose_convert.doc is not different from Start_docx.docx suggesting there weren’t any changes, however, opening both files in an archive manager suggests that the conversion “succeeded”, but Start_doc-saved_through_word.doc has a much larger size indicating that the conversion may not have succeeded correctly.
If this is not a bug, why does the line spacing get changed to Word 2007 style when the base document in which the user document is inserted?
Thank you and best regards