Skip to content

Question: How to merge cropped PDF page with full pdf page in PyPDF? #163

@lananelson

Description

@lananelson

I am trying to merge two pdf pages using PyPDF2:

background_page = background_pdf.getPage(0)
overlay = some_pdf.getPage(0)

# crop overlaying page vertically
overlay.mediaBox.lowerRight = (
    overlay.mediaBox.getUpperRight_x(),
    overlay.mediaBox.getUpperRight_y() / 2
)
# merge
background_page.mergePage(overlay)

Unfortunately cropping doesn't happen. mediaBox of the overlaying page appears to be ignored and I see entire page in the output.

Does anyone have any idea of how I can achieve this?

I posted this on SO as well http://stackoverflow.com/questions/27512246/how-to-merge-cropped-pdf-page-with-full-pdf-page-in-pypdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    is-questionRather a question than an issue. Should usually be a Discussion instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions