How to get the total page count in PDF using JavaScript in AEM Guides | Community
Skip to main content
Level 2
January 23, 2024
Solved

How to get the total page count in PDF using JavaScript in AEM Guides

  • January 23, 2024
  • 1 reply
  • 2423 views

Hi,

 

Using the below code in page layouts, I tried to get the total page count of the PDF.

<span data-field="total-pages" data-format="default">1</span>

total page count is getting added in pdf. But can't able to fetch the value in JS. When trying to fetch the page count it's giving counter(pages) in console.

How to achieve this functionality?

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by DivrajSingh

@kiruthika_r : 

To get total number of pagein PDF you can use below code in Javascript&colon;

              window.ro.layout.numberOfPages

1 reply

DivrajSingh
Adobe Employee
DivrajSinghAdobe EmployeeAccepted solution
Adobe Employee
March 18, 2024

@kiruthika_r : 

To get total number of pagein PDF you can use below code in Javascript&colon;

              window.ro.layout.numberOfPages

Level 2
March 19, 2024

Thanks @divrajsingh. This solution works fine.