After executing MailMerge, we need to move to the END of the document to create an object (a line) and some blank pages (page breaks).
docTemplate.WordDoc.MailMerge.Execute(fieldNames, fieldValues.ToArray());
// add end line
DocumentBuilder builder = new DocumentBuilder(docTemplate.WordDoc);
builder.MoveToDocumentEnd();
Shape endOfContentLine = new Shape(docTemplate.WordDoc, ShapeType.Line);
endOfContentLine.Name = END_OF_WORD_CONTENT;
endOfContentLine.Bounds = new RectangleF(0, 0, 500, 0);
endOfContentLine.StrokeColor = Color.Red; // DEBIG Red for now so we can see it
builder.InsertNode(endOfContentLine);
// add extra pages
for (int i = 0; i <= 5; i++)
{
builder.MoveToDocumentEnd();
builder.InsertBreak(BreakType.PageBreak);
}
Problem) The method DocumentBuilder.MoveToDocumentEnd() is not working as expected.
The red line we create is NOT at the END of the document. There is one line of static text below it (see attached) output_GPRINTER.zip (54.1 KB)
Question) We need to find out the page number where the shape endOfContentLine is printed. It’s not predictable, because we do mail merge above the line.
Question) We need to find out the page number where the shape endOfContentLine is printed. It’s not predictable, because we do mail merge above the line.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.