This topic describes how to obtain the total number of pages, listen to page change events, and jump to a specified page when you use a PDF document.
Obtain the total number of pages
Obtain the total number of pages of the PDF document.
Syntax
Expression.ActivePDF.PagesCountExpression: the document type application object.
Return value
Returns a
numberthat represents the total number of pages.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the total number of pages. const totalPages = await app.ActivePDF.PagesCount; console.log(totalPages); }
Obtain the current page number
Obtain the current page number of the PDF document.
Syntax
Expression.ActivePDF.CurrentPageExpression: the document type application object.
Return value
Returns a
numberthat represents the current page number.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the current page number. const curryPage = await app.ActivePDF.CurrentPage; console.log(curryPage); }
Listen to page change events
Listen to the page change events of the current page.
Syntax
Expression.Sub.CurrentPageChange = eventHandleExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to the page change events of the current page. app.Sub.CurrentPageChange = async (curryPage) => { console.log ('Switch to:', curryPage); }; }
Jump to a specified page
Jump to a specified page in the PDF document.
Syntax
Expression.ActivePDF.JumpToPage(PageNum)Expression: the document type application object.
Parameters
Parameter
Type
Required
Description
PageNum
Number
Yes
The page number to jump to.
Example
async function example() { await instance.ready(); const app = instance.Application; // Jump to the specified page. await app.ActivePDF.JumpToPage(3); }