Skip to content

Is it possible to get "BleedBox" and "TrimBox" value of a page? #1176

Description

@mlove4u

I have some pdf files created by Adobe InDesign (with bleed setting). And I want to crop only the "TrimBox" range of every page to image. Is it possible to get the coordinate?
I can get the info with code:

>>> doc = fitz.open("trimbox.pdf")
>>> page = doc.load_page(0)
>>> xref = page.xref
>>> doc.xref_get_key(xref, "TrimBox")
('array', '[36.8499 36.8499 632.126 878.74]')
>>> doc.xref_get_key(xref, "BleedBox")
('array', '[28.346 28.346 640.629 887.244]')
#
>>> page.mediabox
Rect(0.0, 0.0, 668.9760131835938, 915.5900268554688)
>>> page.cropbox
Rect(0.0, 0.0, 668.9760131835938, 915.5900268554688)

Is there more simple way to do this? Like:

page.trimbox
page.bleedbox

trimbox.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions