public void GenerateGuarantorDeposit(string id) { string filename = "./PRINT/GUARANTOR_DEPOSIT/GUARANTOR_DEPOSIT-" + id + ".docx"; file = new Document(); fileBuilder = new DocumentBuilder(file); Lease document = FindOne(id); Dictionary <string, object> documentDIC = ToDictionnary(document); insertField(documentDIC, document.GetType().Name); foreach (string field in mergeFields) { if (field.Equals("Lease.Deposit")) { fileBuilder.InsertTextInput("TextInput", TextFormFieldType.Regular, "", "Montant de la guarantie : ", 0); fileBuilder.InsertField($"MERGEFIELD {field} €"); fileBuilder.InsertBreak(BreakType.LineBreak); } } fileBuilder.Document.Save("merging-field-" + id + ".docx"); file.MailMerge.Execute(mergeFields.ToArray(), mergeValues.ToArray()); fileBuilder.Document.Save(filename); mergeFields.Clear(); mergeValues.Clear(); }
public void GenerateContract(string id) { string filename = "./PRINT/LEASE_CONTRACT/LEASE_CONTRACT-" + id + ".docx"; file = new Document(); fileBuilder = new DocumentBuilder(file); Lease document = FindOne(id); Dictionary <string, object> documentDIC = ToDictionnary(document); insertField(documentDIC, document.GetType().Name); foreach (string field in mergeFields) { fileBuilder.InsertTextInput("TextInput", TextFormFieldType.Regular, "", $"{field} : ", 0); fileBuilder.InsertField($"MERGEFIELD {field}"); fileBuilder.InsertBreak(BreakType.LineBreak); } fileBuilder.Document.Save("merging-field-" + id + ".docx"); file.MailMerge.Execute(mergeFields.ToArray(), mergeValues.ToArray()); fileBuilder.Document.Save(filename); mergeFields.Clear(); mergeValues.Clear(); }