Skip to main content

GetStartPage

Returns the start page number of the current range.

Syntax

expression.GetStartPage();

expression - A variable that represents a ApiRange class.

Parameters

This method doesn't have any parameters.

Returns

Number

Example

Find the first page where a selected region of text begins in a document.

// How do I determine which page a text selection starts on in a document?

// Locate the opening page of a highlighted span to understand its layout position in a document.

const doc = Api.GetDocument();

const firstParagraph = doc.GetElement(0);
firstParagraph.AddText('This text is on the first page.');

doc.MoveCursorToEnd();
doc.InsertBlankPage();

const secondParagraph = Api.CreateParagraph();
secondParagraph.AddText('This text is on the second page.');
doc.Push(secondParagraph);

const firstRange = firstParagraph.GetRange();
const secondRange = secondParagraph.GetRange();

const resultParagraph = Api.CreateParagraph();
resultParagraph.AddText('First paragraph range starts on page: ' + firstRange.GetStartPage());
resultParagraph.AddLineBreak();
resultParagraph.AddText('Second paragraph range starts on page: ' + secondRange.GetStartPage());
doc.Push(resultParagraph);