Hi aspose guys,
I need to delete empty paragraphs in the first page. But it seems that aspose word can not get the first page of document.
Is there any way to resolve my problem?
Thanks for any help
Hi aspose guys,
doc = new Document(@“d:\test\inputtest.docx”);<o:p></o:p>
NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
foreach (Paragraph para in paragraphs)
// Check all runs in the paragraph for the first page breaks.
foreach (Run run in para.Runs)
// Check empty paragraph to remove
if (string.IsNullOrEmpty(para.ToTxt().Trim()) && para.ParentNode != null)
In case of any ambiguity, please let me know.
Thanks for your help.
This code vill remove untill the first page break. But I only want to delete empty paragraphs in the first page of doc file. Because page break in my files maybe in the 3rd hoac later page.
Is there no way to specify the first page(not first page break) in aspose.word?
Thanks for your request. Word document is flow document and does not contain any information about its layout into lines and pages. Therefore, technically there is no “Page” concept in Word document.
In Aspose.Words we are using our own Rendering Engine to layout document into pages. The Rendering Engine is using for converting to PDF. But, unfortunately, currently, there is no public API to determine where pages start/end.
Aspose.Words uses our own Rendering Engine to layout documents into pages. And we have plans to expose layout information. Your request has been linked to the appropriate issue. You will be notified as soon as this feature is supported.
Also, I think, as a workaround you can try using PageNumberFinder class suggested by Adam in this thread: