any lib to extract pages form pdf and then merge?

Discussion in 'Python' started by oyster, May 26, 2009.

  1. oyster

    oyster Guest

    I want to extract some pages from vary pdf files, then write them
    with/witout rotation into one new pdf file. something likes this
    [py]
    import gfx
    doc = gfx.open("pdf", r"Theory.pdf")
    pdf = gfx.PDF()
    for pagenr in [1,5,7]:
    page = doc.getPage(pagenr)

    if pagenr==1:
    page.rotate(90) #for some pages

    pdf.startpage(page.width, page.height)
    page.render(pdf)
    pdf.endpage()
    pdf.save("new pdf.pdf")
    [/py]

    I have tried pypdf, but it errs and exits on some of my pdfs(no, the
    files have no password)

    can someone suggest on such a lib for python on windows/or a pure C-dll?
    (I mean pdf page->pdf, not pdf page->pic->pdf)

    thanx
    oyster, May 26, 2009
    #1
    1. Advertising

  2. oyster

    CTO Guest

    On May 26, 12:47 am, oyster <> wrote:
    > I want to extract some pages from vary pdf files, then write them
    > with/witout rotation into one new pdf file. something likes this
    > [py]
    > import gfx
    > doc = gfx.open("pdf", r"Theory.pdf")
    > pdf = gfx.PDF()
    > for pagenr in [1,5,7]:
    >     page = doc.getPage(pagenr)
    >
    >     if pagenr==1:
    >         page.rotate(90)                                         #for some pages
    >
    >     pdf.startpage(page.width, page.height)
    >     page.render(pdf)
    >     pdf.endpage()
    > pdf.save("new pdf.pdf")
    > [/py]
    >
    > I have tried pypdf, but it errs and exits on some of my pdfs(no, the
    > files have no password)
    >
    > can someone suggest on such a lib for python on windows/or a pure C-dll?
    > (I mean pdf page->pdf, not pdf page->pic->pdf)
    >
    > thanx


    I'd recommend reportlab <URL: http://www.reportlab.org/>. It is mostly
    geared towards creating new PDFs, but it is pretty much best-of-breed
    AFAICT.

    Geremy Condra
    CTO, May 26, 2009
    #2
    1. Advertising

  3. oyster

    David Boddie Guest

    On Tuesday 26 May 2009 06:47, oyster wrote:

    > I want to extract some pages from vary pdf files, then write them
    > with/witout rotation into one new pdf file. something likes this


    [...]

    > I have tried pypdf, but it errs and exits on some of my pdfs(no, the
    > files have no password)


    Maybe you could get in touch with the author to try and work around these
    problems.

    David
    David Boddie, May 26, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Isaac

    extract PDF pages

    David Isaac, Oct 13, 2005, in forum: Python
    Replies:
    2
    Views:
    378
    Larry Bates
    Oct 13, 2005
  2. est
    Replies:
    1
    Views:
    609
    Diez B. Roggisch
    Feb 16, 2008
  3. monogeo
    Replies:
    0
    Views:
    472
    monogeo
    Apr 18, 2009
  4. Replies:
    0
    Views:
    270
  5. P Rajmohan Banavi-A17190

    extract contents from pdf (pdf reader)

    P Rajmohan Banavi-A17190, Sep 22, 2008, in forum: Ruby
    Replies:
    1
    Views:
    131
    Gregory Brown
    Sep 22, 2008
Loading...

Share This Page