Hello, i'm trying to fulfill document with data from my database. I gave some placeholders in word document e.g. {{customerName}}. I replace this values with document.Replace().
Now, fifth row in table should be dynamical as this property is List of objects. Please help me how to render rows in particular position in table and fill it with data.
Thank you in advance,
Danilo
using (var document = new Document())
{
var assembly = Assembly.GetAssembly(typeof(GeneratePdfQuery));
var pom = (TypeOfDocumentEnum)query.TypeOfDocument;
Stream stream = assembly.GetManifestResourceStream($"G7.Domain.StatementTemplates.{pom.ToString()}.docx");
document.LoadFromStream(stream, FileFormat.Docx2013);
foreach (PropertyInfo prop in query.GetType().GetProperties())
{
document.Replace(FormatString(prop.Name), prop.GetValue(query).ToString().Trim(), true, true);
}
using (var writeStream = new MemoryStream())
{
document.SaveToFile($"{query.FileName}.pdf", FileFormat.PDF);
document.SaveToStream(writeStream, FileFormat.PDF);
return writeStream.ToArray();
}
}