These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to get the total page number of a pdf file using javascript?

prakash philip
Registered: Nov 25 2009
Posts: 7
Answered

Hi,
I am uploading PDF files in my application.I need to know that how many number of pages are there in PDF file?
So that I can display it on my flex application.I have disabled the in-built controls for displaying the number of pages and other controls.
Can any one tell me how to do this?

Regards
Prakash Philip

My Product Information:
Acrobat Standard 9.2, Windows
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
Are you using Acrobat JavaScript? If so, then this.numPages will return the number of pages in a PDF.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

prakash philip
Registered: Nov 25 2009
Posts: 7
Hi
Am using acrobat javascript only.
case "Count":
this.numPages;
break;
this is the code an using inside the javascript.
and Count is the message am passing into tat.
am not able to get the total page number.
can u plz send me little code for this problem.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
First, 'case' is part of the 'switch' statement and when used outside of the 'switch' statement causes a syntax error. To define a variable name use the 'var' statement.
var Count = this.numPages; define count and set it to the number of pagesapp.alert('This document has ' + Count + 'pages.', 2, 0);

George Kaiser

prakash philip
Registered: Nov 25 2009
Posts: 7
Hi,
I got the total page number of PDF file using this function.

var Count = this.numPages; define count and set it to the number of pages
app.alert('This document has ' + Count + 'pages.', 2, 0);

Now i want to pass the value of "Count" into my flex application.

Can any one tell me how to do this?

Regards
Prakash.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Have you looked at the Acrobat SDK and the samples for interfacing to various languages?

George Kaiser