Closed PrzemyslawKlys closed 1 year ago
Potentiall solution:
using (WordprocessingDocument wordDocument = WordprocessingDocument.Open(@"your_docx_file.docx", true)) { string altChunkId = "AltChunkId5"; MainDocumentPart mainDocPart = wordDocument.MainDocumentPart; AlternativeFormatImportPart chunk = mainDocPart.AddAlternativeFormatImportPart( AlternativeFormatImportPartType.Rtf, altChunkId); // Read RTF document content. string rtfDocumentContent = File.ReadAllText("your_rtf_document.rtf", Encoding.ASCII); using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(rtfDocumentContent))) { chunk.FeedData(ms); } AltChunk altChunk = new AltChunk(); altChunk.Id = altChunkId; // Embed AltChunk after the last paragraph. mainDocPart.Document.Body.InsertAfter( altChunk, mainDocPart.Document.Body.Elements<Paragraph>().Last()); mainDocPart.Document.Save(); }
Will be solved by:
Potentiall solution: