We have a table with table start and table end
The table has a column header with book marks and a body with book marks where we are inserting text (information about an object) using mail merge.
With every new object, we want to start a new header. We also want the header to appear on the next page when the body text continues into the next page. However, we always want to start inserting the header column and body text on a new page when we start a new object.
We have attached a sample where the new table for the new object starts right after the previous object information is completed. Please help
Hi Allan,
Thanks for your inquiry. Please set “page break before” property of first paragraph of table to true in your template document. See the attached image for detail. Please use following modified code snippet to get the desired output. We have attached the input and output documents with this post for your kind reference. Hope this helps you.
///
/// Copy a part of a document and paste it into another document
///
Document doc = new Document(MyDir + "InputPageBreak.doc");
CustomMergerHandler FieldMergeHandler = new CustomMergerHandler();
DataTable dtIntv = new DataTable();
dtIntv = dt;
if (dtIntv != null)
{
dtIntv.TableName = "Result1";
doc.MailMerge.CleanupOptions =
MailMergeCleanupOptions.RemoveContainingFields |
MailMergeCleanupOptions.RemoveEmptyParagraphs |
MailMergeCleanupOptions.RemoveUnusedFields |
MailMergeCleanupOptions.RemoveUnusedRegions;
doc.MailMerge.FieldMergingCallback = FieldMergeHandler;
doc.MailMerge.ExecuteWithRegions(dtIntv);
}
doc.Save(MyDir + "Out v16.6.0.doc");