| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How Internet Explorer gets PDF page count
Hi friends,
Thanks in advance. I am using Acrobat Reader Browser document to show PDF file in my application. But as I drag drop PDF file into internet explorer, it shows page count of PDF file. How can I get page count in PDF file through C++/VC++. Thanks, Subhash Madhukar |
|
#2
|
|||
|
|||
|
Re: How Internet Explorer gets PDF page count
Internet Explorer uses a plug-in to display PDF files.
That plug-in explores the components (they are called "objects" by Adobe) inside the PDF file. It builds a tree of pages from the "objects" declared with "/Type / Pages". But this is not easy because objects cannot be accessed sequentially. You have to find the tables (usually there are more than one table) of indexes of objects, and objects might be compressed. Edit: I forgot the "Linearized" object, which is probably the one you had in mind. It is a special object containing an argument /N containing the number of pages of the document. Many PDF files are "linearized", i.e. they have a first page which can be displayed very quickly, and the other pages are loaded later, and that's when you see Internet Explorer telling you it is currently loading the other pages, and it knows the total number of pages thanks to that /N argument of the /Linearized object. Last edited by olivthill2; October 22nd, 2009 at 03:43 AM. |
|
#3
|
|||
|
|||
|
Re: How Internet Explorer gets PDF page count
Hi olivthill2,
Thanks for reply. I know /Count or /Type /Page syntax to count the no. of pages. I opened PDF in binary form using CFile and try to read single line and count " /Type /Page " pattern but as it is binary file, I could not able to read single line. Line end is specified by '\n' or '\r' or '\r\n' i.e. 0x0A or 0x0D 0r 0x0D 0x0A. To check the regular expression I used CAtlRegExp class. If i check all these patterns and read single byte at a time, it takes lot of time. So can you please provide me some c++/VC++ code sample if possible to read the single line in PDF or get the page count. Thanks, Subhash Madhukar |
|
#4
|
||||
|
||||
|
Re: How Internet Explorer gets PDF page count
To get the page count, you will need some way to read it from the PDF, that is usually done by PDF reader. You should try for some PDF Library whcih can give you this.
http://www.wpcubed.com/products/pdfviewer/index.htm
__________________
Regards, Ramkrishna Pawar |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|