Results 1 to 10 of 10

Thread: [RESOLVED] To find the starting page number and end page number of a pdf file

  1. #1

    Thread Starter
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Resolved [RESOLVED] To find the starting page number and end page number of a pdf file

    Dear all,

    Can anyone help me to find the starting page number and the end page number of a pdf file. The pdf file may start with any number (for example the pdf file can start with the page number 10 and end with 20) the code should find out the start pare number 10 and the end page number 20.

    Thanks in advance.

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: To find the starting page number and end page number of a pdf file

    PDF files can start with roman numerals or any made up characters as well.

    Howevre, all PDF pages have an internal pageIndex, which is the actual index of the page within the document.

    So even if the first four pages of a 10 page PDF were labeled with roman numerals, the fifth page could be labeled 'Page 1', but it internally has a pageIndex equal to 5.

    So the question to you is, do you want the internal page index? If you do, that is easy to obtain. If not, it gets severely more complicated.

  3. #3

    Thread Starter
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: To find the starting page number and end page number of a pdf file

    Yes Nemaroller I want to know the internal page index. Can you help me to find out this. I have attached the bmp file with this please check it.
    Attached Files Attached Files

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: To find the starting page number and end page number of a pdf file


  5. #5

    Thread Starter
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: To find the starting page number and end page number of a pdf file

    This is not working Nemaroller.

  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: To find the starting page number and end page number of a pdf file

    If you just want it done fast, reference an open-source C# PDF library - use it to load the document and give you a page count.

    Try PDFSharp:
    http://sourceforge.net/projects/pdfsharp
    (beta 4)

    I was able to get the page count by using two lines of code:

    Code:
    PdfDocument theDoc = PdfReader.Open(@"C:\test2.pdf");
    Console.WriteLine(theDoc.PageCount);
    theDoc.Close();

  7. #7

    Thread Starter
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: To find the starting page number and end page number of a pdf file

    My friend I don't want to get the page count, I can able to get the page count. I want to get the page number of a pdf file. The page number is displayed at the bottom of the pdf file(not inside the page). I want to get that number.

  8. #8
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: To find the starting page number and end page number of a pdf file

    I dont know if this will help, but I had something to do like this before where I wanted to count the number of pages in a pdf file.

    http://www.codeproject.com/useritems...select=1778090

    You could check the page with the code, what it does is check through a pdf files using a regular pattern to search for a string at the end of every page.

    I dont know if you could use this to help,


    Jennifer

  9. #9

    Thread Starter
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: To find the starting page number and end page number of a pdf file

    vb Code:
    1. using Acrobat;
    2. using AFORMAUTLib;
    3.  
    4. public static DisplayPDFPageNumber(string FilePath)
    5. {
    6.             AcroPDDocClass objPages = new AcroPDDocClass();
    7.             objPages.Open(FilePath);
    8.             int TotalPDFPages = objPages.GetNumPages();
    9.             objPages.Close();
    10.  
    11.             AcroAVDocClass avDoc = new AcroAVDocClass();
    12.             avDoc.Open(FilePath, "Title");
    13.  
    14.             IAFormApp formApp = new AFormAppClass();
    15.             IFields myFields = (IFields)formApp.Fields;
    16.             for (int i = 0; i < TotalPDFPages; i++)
    17.             {
    18.                 string PageNumber = myFields.ExecuteThisJavascript("event.value=this.getPageLabel(" + i + ");");
    19.                 MessageBox.Show("Page " + i + " : " + PageNumber  + "");
    20.             }
    21.  
    22. }
    I have found the page number of a pdf file by using this code. This code is working fine.

  10. #10

    Thread Starter
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: To find the starting page number and end page number of a pdf file


    using Acrobat;
    using AFORMAUTLib;

    public static DisplayPDFPageNumber(string FilePath)
    {
    AcroPDDocClass objPages = new AcroPDDocClass();
    objPages.Open(FilePath);
    int TotalPDFPages = objPages.GetNumPages();
    objPages.Close();

    AcroAVDocClass avDoc = new AcroAVDocClass();
    avDoc.Open(FilePath, "Title");

    IAFormApp formApp = new AFormAppClass();
    IFields myFields = (IFields)formApp.Fields;
    for (int i = 0; i < TotalPDFPages; i++)
    {
    string PageNumber = myFields.ExecuteThisJavascript("event.value=this.getPageLabel(" + i + ");");
    MessageBox.Show("Page " + i + " : " + PageNumber + "");
    }

    }

    This code is working fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width