-
Greetings. Let's say that I have a fitz.Rect object, which define the bounding box I want to crop out from PDF. How to use it to crop the PDF w.r.t all the elements (svg, text, etc.)? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Geometry objects like rectangles, points and matrices exist without dependency to anything else in the world. They are nothing than the set of numbers by which they are defined. The visible part of a PDF page is defined via its Setting the cropbox only restricts what is visible of the page. The page content is not changed in any way if the cropbox is changed. Changing the cropbox again (e.g. setting it to the full |
Beta Was this translation helpful? Give feedback.
-
@JorjMcKie , thanks for your answer! But is it possible in anyway to remove objects outside of cropbox in an elegant and easy way using fitz? |
Beta Was this translation helpful? Give feedback.
Yes. This works via so-called redactions. You define redaction annotations for desired rectangles and then call a page method to "apply" all redactions defined on it.
Thereafter, text content intersecting an annotation rectangle wil be physically gone. Same is true fro any hyperlinks. for images, there is a 3-fold choice:
So to delete page content outside a given rectangle, you need to define (up to) four annotation rectangles covering the areas outside and then execute
apply_redactions()
.