Free Support Forum -

Aspose.Words - Determining page position

Received : 2007/08/27 14:12:52
Message : Is there a way to determine vertical page position of text? Using MS Word this is possible using the Selection.Information(wdVerticalPositionRelativeToPage) function. Does something similar exist in Aspose?

This message was posted using Aspose.Live 2 Forum


Thanks for your request. It is not quite clear for me what you want to do. Maybe you can try to use Section.PageSetup.VerticalAlignment or Section.PageSetup.TopMargin.

I hope that it will help you.

What I'm trying to figure out is how much space is left at the bottom of a page so that I can insert a page break if needed. Any ideas?

Thanks in advance.


Thank you for your interest in Aspose products.

Don't use page breaks for that. It's better to insert section break - next page. It is guaranteed to start next element from the next page regardless of what fits on the previous one. Even if you put the break on the last fitting line you will never get a blank page. Is this what you want to control?


The problem we are having is we need to determine what the available space remaining on the page. We want to be able to know the remaining space so we can determine the following:

1. Do we have enough remaining space on a page to add an additional paragraph/table, etc.

2. If there is not enough space remaining we can insert a section break - net page or page break.

(We need a section break - next page or page break as a count to know the page number.)

Is there an example of this?



Thanks for additional information. If your document contains text only then you can try to determine rows count on page and insert page break. See the following code. But note that it is the exact algorithm.

Document doc = new Document(@"171_93811_bustosfj\in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

ArrayList list = new ArrayList();

//rows count

int rowsCount = 0;

for (int i = 0; i < doc.FirstSection.Body.Paragraphs.Count; i++)


Paragraph par = doc.FirstSection.Body.Paragraphs[i];

//get length of current paragraph

int charCount = par.Range.Text.Length;

if (charCount > 0)


//calculate row count

rowsCount += (charCount / 80) + 1;






if (rowsCount > 50)




rowsCount = 0;



//inser page breaks

for (int j = 0; j < list.Count; j++)


builder.MoveTo((list[j] as Paragraph));




I hope that it will help you to find solution for your problem.

Best regards.

Doe this adjust based on the font size?


This code will work for the following document settings:

Font name = “Times New Roman”

Font size = 12

Line spacing = Single

All settings set by default.

You can try to adapt this code for your document.

Best regards.

I have the same problem.

I have an image with 75 % of page size.I need to insert that image in a specific location using find and replace text.If the current page has more than 50% of page size remaining after current node,then i will shrink that image and fit it into same page,otherwise i will insert into next page.

How can i get the remaining space from the current node.


Thanks for your inquiry. MS Word document is flow document and does not contain any information about its layout into lines and pages. So there is no direct way to determine where page starts or ends and determine remaining space on the particular page using Aspose.Words.

Best regards,

The issues you have found earlier (filed as WORDSNET-2978) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.