public async Task <byte[]> GenerateDocumentAsync(Guid idTemplate, IDocumentGeneratorModel parameters, byte[] content = null)
 {
     return(await DocumentGeneratorHelper.TryCatchWithLogger(async() =>
     {
         if (content == null)
         {
             content = await GetLatestVersionAsync(idTemplate);
         }
         WordGeneratorBuilder builder = new WordGeneratorBuilder();
         return builder.GenerateWordDocument(content, parameters.DocumentGeneratorParameters);
     }, _logger, LogCategories));
 }
 public byte[] AppendTable(IDocumentGeneratorModel parameters, byte[] content)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         stream.Write(content, 0, content.Length);
         using (WordprocessingDocument doc = WordprocessingDocument.Open(stream, true))
         {
             WordGeneratorBuilder builder = new WordGeneratorBuilder();
             Table wordTable = builder.BuildWordTable(parameters.DocumentGeneratorParameters);
             if (wordTable != null)
             {
                 doc.MainDocumentPart.Document.Body.Append(new Paragraph());
                 doc.MainDocumentPart.Document.Body.Append(wordTable);
             }
         }
         return(stream.ToArray());
     }
 }