Get Page Info EJ2 TypeScript Pdfviewer control

16 May 20251 minute to read

The PDF Viewer library allows you to retrieves the information of a specified page in the viewer using the getPageInfo() method.This provides essential information such as the height, width and rotation.

The following steps are used to getPageInfo.

Step 1: Follow the steps provided in the link to create a simple PDF Viewer sample.

Step 2: The following code snippet to implement the functionality for retrieving height, width and rotation of a specified page in the viewer.

 <button id="getPageInfo">getPageInfo</button>
// Event listener for getting page information
document.getElementById('getPageInfo')?.addEventListener('click', function() {
    // Set the page index for which info is required
    let pageIndex: number = 0;

    // To Retrieve and log the page information
    console.log(pdfviewer.getPageInfo(pageIndex));

     // Log the specific page information details to the console
    const pageInfo:PageInfoModel = pdfviewer.getPageInfo(pageIndex);
    console.log(`Page Info for Page Index ${pageIndex}:`);
    console.log(`Height: ${pageInfo.height}`);
    console.log(`Width: ${pageInfo.width}`);
    console.log(`Rotation: ${pageInfo.rotation}`);
  });

By following these steps, you can successfully integrate and use the get page info API in the EJ2 PDF Viewer.

View sample in GitHub