CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Binding Data to Silverlight 4.0 Controls Using ASP.NET MVC Framework 2.0
  • ADO.NET Data Services in the .NET Framework
  • Visual C++ Programming: What's new for MFC library in VC++ 2010?
  • Microsoft Visual Studio LightSwitch and What It Can Do For You

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old October 21st, 2009, 07:57 PM
    smadhukar2000@gmail.com smadhukar2000@gmail.com is offline
    Junior Member
     
    Join Date: Apr 2008
    Posts: 10
    smadhukar2000@gmail.com is an unknown quantity at this point (<10)
    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
    Reply With Quote
      #2    
    Old October 22nd, 2009, 03:37 AM
    olivthill2 olivthill2 is offline
    Member
     
    Join Date: Apr 2009
    Posts: 457
    olivthill2  is a jewel in the rough (300+)olivthill2  is a jewel in the rough (300+)olivthill2  is a jewel in the rough (300+)olivthill2  is a jewel in the rough (300+)
    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.
    Reply With Quote
      #3    
    Old October 23rd, 2009, 03:54 AM
    smadhukar2000@gmail.com smadhukar2000@gmail.com is offline
    Junior Member
     
    Join Date: Apr 2008
    Posts: 10
    smadhukar2000@gmail.com is an unknown quantity at this point (<10)
    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
    Reply With Quote
      #4    
    Old October 23rd, 2009, 04:10 AM
    Krishnaa's Avatar
    Krishnaa Krishnaa is offline
    Microsoft MVP
    Power Poster
     
    Join Date: Aug 1999
    Location: <Classified>
    Posts: 6,867
    Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)Krishnaa has a reputation beyond repute (3000+)
    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
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 08:45 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.