PDF count pages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jose Benito Gonzalez Lopez

    #1

    PDF count pages

    Hi there,

    Does anyone know how I could do in order
    to get/count the number of pages of a PDF file? (from
    python of course ;) )

    Thanks beforehand.

    Cheers,
    Jose

    --

    Jose Benito Gonzalez Lopez

    CERN Document Server ** <http://cds.cern.ch/> ** <cds.support @ cern.ch>
    InDiCo Project ** <http://indico.cern.ch> ** <indico-project @ cern.ch>
    CDSconv ** <http://cdsconv.cern.ch >
    Room: Bldg 513-R-027 ** Voice: +41 22 76 78893

  • Andreas Lobinger

    #2
    Re: PDF count pages

    Aloha,

    Jose Benito Gonzalez Lopez wrote:[color=blue]
    > Does anyone know how I could do in order
    > to get/count the number of pages of a PDF file?[/color]

    Like this ?
    Python 2.2.2 (#3, Apr 10 2003, 17:06:52)
    [GCC 2.95.2 19991024 (release)] on sunos5
    Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
    >>> import pdffile
    >>> pf = pdffile.pdffile ('../rfc1950.pdf')
    >>> import pages
    >>> pp = pages.pages(pf)
    >>> len(pp.pagelist )[/color][/color][/color]
    10[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]

    This is an example of the usage of pdfplayground. pdfplayground
    is available via sourceforge. There is no package at the
    moment, but you should be able to check out via anon-cvs.

    Wishing a happy day
    LOBI

    Comment

    • davidb@mcs.st-and.ac.uk

      #3
      Re: PDF count pages

      Andreas Lobinger wrote:[color=blue]
      >
      > Jose Benito Gonzalez Lopez wrote:[color=green]
      > > Does anyone know how I could do in order
      > > to get/count the number of pages of a PDF file?[/color]
      >
      > Like this ?[/color]
      [...][color=blue][color=green][color=darkred]
      > >>> import pdffile
      > >>> pf = pdffile.pdffile ('../rfc1950.pdf')
      > >>> import pages
      > >>> pp = pages.pages(pf)
      > >>> len(pp.pagelist )[/color][/color][/color]
      [...]

      That's interesting. Here's my equivalent example:

      Python 2.3.3 (#1, May 2 2004, 15:04:07)
      [GCC 3.2.2] on linux2
      Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
      >>> from pdftools import pdffile
      >>> doc = pdffile.PDFDocu ment("PDFSPEC.p df")
      >>> doc.count_pages ()[/color][/color][/color]
      518

      The API shown above is from an unreleased version of pdftools
      (http://www.boddie.org.uk/david/Proje...hon/pdftools/).
      [color=blue]
      > This is an example of the usage of pdfplayground. pdfplayground
      > is available via sourceforge. There is no package at the
      > moment, but you should be able to check out via anon-cvs.[/color]

      I browsed the code in CVS and it looks like a pretty comprehensive
      implementation. Maybe we should join forces.

      David

      Comment

      • davidb@mcs.st-and.ac.uk

        #4
        Re: PDF count pages

        Andreas Lobinger wrote:[color=blue]
        >
        > Jose Benito Gonzalez Lopez wrote:[color=green]
        > > Does anyone know how I could do in order
        > > to get/count the number of pages of a PDF file?[/color]
        >
        > Like this ?[/color]
        [...][color=blue][color=green][color=darkred]
        > >>> import pdffile
        > >>> pf = pdffile.pdffile ('../rfc1950.pdf')
        > >>> import pages
        > >>> pp = pages.pages(pf)
        > >>> len(pp.pagelist )[/color][/color][/color]
        [...]

        That's interesting. Here's my equivalent example:

        Python 2.3.3 (#1, May 2 2004, 15:04:07)
        [GCC 3.2.2] on linux2
        Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
        >>> from pdftools import pdffile
        >>> doc = pdffile.PDFDocu ment("PDFSPEC.p df")
        >>> doc.count_pages ()[/color][/color][/color]
        518

        The API shown above is from an unreleased version of pdftools
        (http://www.boddie.org.uk/david/Proje...hon/pdftools/).
        [color=blue]
        > This is an example of the usage of pdfplayground. pdfplayground
        > is available via sourceforge. There is no package at the
        > moment, but you should be able to check out via anon-cvs.[/color]

        I browsed the code in CVS and it looks like a pretty comprehensive
        implementation. Maybe we should join forces.

        David

        Comment

        • Andreas Lobinger

          #5
          OT: Re: PDF count pages

          Aloha,

          davidb@mcs.st-and.ac.uk wrote:[color=blue]
          > Andreas Lobinger wrote:[color=green][color=darkred]
          >> >>> import pdffile[/color][/color]
          > I browsed the code in CVS and it looks like a pretty comprehensive
          > implementation. Maybe we should join forces.[/color]

          I have problems contacting you via the given e-mail adress.

          Wishing a happy day
          LOBI

          Comment

          Working...