I am currently working on a project where I merge 3 documents into one new one. To add them in, I am creating an AltChunk method to contain the documents.
My question is there is a conflict on the styling between the three. By that, I mean I save one with a table that has red text underneath. However, once the three merge together into the new one, that document's styling is reset to plain black text. Is there a way to merge the styling of all three into this new document?
Below is my code of how I am merging in the documents (I don't show the top portion because all of it is alright so far).
using (WordprocessingDocument package = WordprocessingDocument.Create(fileName, DocumentFormat.OpenXml.WordprocessingDocumentType.Document))
{
...
#region Append Non-Standard Section Template
var nssAltChunkId = "AltChunkIdNSS" + this.AopPlanId.Value.ToString();
var nssChunk = package.MainDocumentPart.AddAlternativeFormatImportPart(
AlternativeFormatImportPartType.WordprocessingML, nssAltChunkId);
using (var fileStream = new MemoryStream(nssBuffer))
{
nssChunk.FeedData(fileStream);
}
var nssAltChunk = new DocumentFormat.OpenXml.Wordprocessing.AltChunk();
nssAltChunk.Id = nssAltChunkId;
package.MainDocumentPart.Document.Body.InsertAfter(nssAltChunk, package.MainDocumentPart.Document.Body.Elements<Paragraph>().Last());
#endregion
... //Next 2 documents are the same way
package.MainDocumentPart.Document.Save();
}
Any help would be appreciated. Thanks.
Edit: I changed to using DocumentBuilder from PowerTools, however, that still does not solve the issue of merging the styles. Any suggestions would be appreciated.