Hi,
we are currently experiencing an issue in merging two documents.
Background: we have document templates with the stationery (with logos, header & footer). We receive in input a word document and we apply the template by merging this document in the template.
Issue: the pasted document is loosing all the line spacing/paragraph styling. Looking at the merged document I also note in the styles bar a new style named "Normal_GUID" where GUID is a 36 char GUID code.
I'm currently using this code
foreach (Section sec in docContent.Sections)
{
foreach (DocumentObject obj in sec.Body.ChildObjects)
{
docTemplate.LastSection.Body.ChildObjects.Add(obj.Clone());
}
}
I've replaced this code with (fileformat is "docx")
MemoryStream ms = new MemoryStream();
docContent.SaveToStream(ms, FileFormat(inputFormat));
docTemplate.InsertTextFromStream(ms, FileFormat(inputFormat));
Using this code the formatting of the pasted content is fully preserved but:
- I have a first empty page
- the footer of the first page (template sets a footer only in the first page) has the formatting damaged with extra line spacing.
- the is no "Normal_GUID" Style in the Style bar (which is good)
What's really strange is that if in the method
MemoryStream ms = new MemoryStream();
docTemplate.SaveToStream(ms, FileFormat(outputFormat));
i use "pdf" as output format and not "docx" everything is ok. With "doc" or "rtf" output format I have the same issue
So, this looks like something wrong in the SaveToStream
Any Hints?
Thanks!