antonmihaylov / OpenXmlTemplates

Word .docx templating system that is designer (no scripting tags) and server-friendly (no word installation required)
GNU Lesser General Public License v3.0
89 stars 25 forks source link

How to get byte array out of document, generated with TemplateDocument #39

Closed ulebule closed 10 months ago

ulebule commented 10 months ago
using var doc = new TemplateDocument("path/to/my/document.docx");
var src = new VariableSource(jsonString); 
var engine = new DefaultOpenXmlTemplateEngine();
engine.ReplaceAll(doc, src);
doc.SaveAs("result.docx");      // this line saves document to file, but I need byte[], cannot save files to disk
ulebule commented 10 months ago

Sorry never mind, found out the method doc.WordprocessingDocument.Clone(memoryStream);