About blank page removal using Control Char option in Aspose word template

Hi,

Could you please help me on remove blank page appears at end of the document while using <<[ControlChar.PageBreak]>> option in aspose word template using C# code Linq reporting engine

@rose.thomas

Summary

The blank page you see at the end of the generated document is caused by the <<[ControlChar.PageBreak]>> placeholder. When the template is processed, Aspose.Words replaces this placeholder with a page break. If the page break is the very last element in the document, Word treats it as the start of a new (empty) page, which results in the extra blank page.

Why it happens

  • ControlChar.PageBreak is a literal page‑break character. After the report engine substitutes the placeholder, the document ends with a page‑break node.
  • Word’s pagination engine always creates a new page after a page break, even if there is no content following it. Hence the final empty page.

What to do next

  1. Avoid inserting a trailing page break – only add the placeholder when you really need a break.
// Example: add the placeholder only if the current section is not the last one
if (!isLastSection)
{
templateBuilder.Append("<<[ControlChar.PageBreak]>>");
}
  1. Remove the last page‑break after the document is generated.
// Load the generated document
var doc = new Aspose.Words.Document("output.docx");

// Get the last node in the body
var lastNode = doc.LastSection.Body.LastChild;
if (lastNode != null && lastNode.NodeType == Aspose.Words.NodeType.ControlChar)
{
var ctrl = (Aspose.Words.ControlChar)lastNode;
if (ctrl.Type == Aspose.Words.ControlCharType.PageBreak)
ctrl.Remove(); // removes the trailing page break
}

doc.Save("output_clean.docx");
  1. Trim empty paragraphs – sometimes a page break is followed by an empty paragraph that also forces a blank page.
doc.RemoveEmptyParagraphs(); // extension method available in Aspose.Words
  1. Check section settings – ensure the last section does not have SectionStart.NewPage or PageSetup.RestartPageNumbering that could force an extra page.
doc.LastSection.PageSetup.SectionStart = Aspose.Words.SectionStart.Continuous;
  1. Validate with the latest Aspose.Words version – if you are on an older release, upgrade, as newer versions contain fixes for handling trailing control characters more gracefully.

If the problem persists after trying the steps above, capture a minimal reproducible example (template, code snippet, and Aspose.Words version) and share it with Aspose support for deeper investigation.

:warning: I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.

SDK version unclear — refer to the official release notes before applying this guidance.

@rose.thomas The question is already answered here:
https://forum.aspose.com/t/about-addition-of-blank-page-in-aspose-word-template-dynamically-using-linq-reporting-engine/321488/7