using (WordprocessingDocument myDoc = WordprocessingDocument.Create(resultDoc, DocumentFormat.OpenXml.WordprocessingDocumentType.Document, true)) { MainDocumentPart mainPart = myDoc.AddMainDocumentPart(); new DocumentFormat.OpenXml.Wordprocessing.Document(new Body()).Save(mainPart); mainPart.Document.Body = new Body(new Paragraph()); // Paragraph para = new Paragraph(new Run(new Break() { Type = BreakValues.Page })); // mainPart.Document.Body.InsertAfter(para, mainPart.Document.Body.LastChild); string altChunkId = "AltChunkId" + count; AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart( AlternativeFormatImportPartType.WordprocessingML, altChunkId); using (FileStream fileStream = System.IO.File.Open(@"cover.docx", FileMode.Open)) { chunk.FeedData(fileStream); } chunk.FeedData(coverDoc); AltChunk altChunk = new AltChunk(); altChunk.Id = altChunkId; mainPart.Document.Body.InsertAfter(altChunk, mainPart.Document.Body.Elements<Paragraph>().Last()); mainPart.Document.Save(); myDoc.Close(); count = count + 1; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)