Page

更新时间:
复制 MD 格式

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.PagesCount

    Expression: the document type application object.

  • Return value

    Returns a number that 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.CurrentPage

    Expression: the document type application object.

  • Return value

    Returns a number that 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 = eventHandle

    Expression: 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);
    }