We are generating a pdf document via a Mail Merge and are trying to figure out how we can hide entire rows of data (without displaying a blank row).
Our word docs consist purely of Ms Word table rows with 2 columns - one for the label and one for the data. The data field is a MergeField.
In the example below - if we wanted to hide the entire email row of data how could we do this?
Playing around with it - I have managed to hide the label on that row but it still displays the row. The row just contains no data. This results in a blank line displaying on the doc which we do not want. The mobile should display directly undernearh the last name if the email is empty.
Any idea how we can do this?
Thanks
EXAMPLE WORD DOC TEMPLATE DEFINITION
First Name: <<First_Name>>
Last Name: <<Last_Name>>
Email: <<Email>>
Mobile: <<Mobile>>
C# CODE THAT PERFORMS THE MERGE
- Code: Select all
private PdfDocument RunMailMerge(string docLocation, Tuple<DataSet, List<DictionaryEntry>> dsData)
{
try
{
Document document = new Document();
document.LoadFromFile(docLocation);
document.MailMerge.ExecuteWidthNestedRegion(dsData.Item1, dsData.Item2);
Spire.Pdf.PdfDocument pdfdoc;
using (MemoryStream stream = new MemoryStream())
{
document.SaveToStream(stream, Spire.Doc.FileFormat.PDF);
document.Close();
pdfdoc = new Spire.Pdf.PdfDocument(stream);
}
return pdfdoc;
}
catch(Exception ex)
{
throw new InvalidOperationException("RunMailMerge error for document " + docLocation, ex);
}
}