Free Support Forum -

How to search blank page in word template using Aspose.word


We are having window applicationn and using C# for development.

We do have word template file and it is having blank page.We want to search blank page and want to write data into this blank page.Can you please help us to achive this ?

Hi Atos,

Thanks for your inquiry. Please use the following code snippet to achieve your requirements. I suggest you please read following documentation links.

Hope this helps you. Please let us know if you have any more queries.

<span style=“font-size:10.0pt;
font-family:“Courier New”;color:#2B91AF;mso-font-kerning:0pt;mso-ansi-language:
PL;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:
“Courier New”;mso-font-kerning:0pt;mso-ansi-language:PL;mso-no-proof:yes”> doc
= new Document(MyDir

  • “in.docx”);<o:p></o:p>

DocumentBuilder builder = new DocumentBuilder(doc);

String PageText = "";

LayoutCollector lc = new LayoutCollector(doc);

int pages = lc.GetStartPageIndex(doc.LastSection.Body.LastParagraph);

for (int i = 1; i <= pages; i++)


ArrayList nodes = GetNodesByPage(i, doc);

foreach (Paragraph para in nodes)


PageText += para.ToString(SaveFormat.Text).Trim();


//Empty Page

if (PageText == "")



builder.Writeln("Aspose.Words for .NET");



PageText = "";


//Get Paragraph nodes by page number

private ArrayList GetNodesByPage(int page, Document document)


ArrayList nodes = new ArrayList();

LayoutCollector lc = new LayoutCollector(document);

foreach (Paragraph para in document.GetChildNodes(NodeType.Paragraph, true))


if (lc.GetStartPageIndex(para) == page)



return nodes;