Skip to content

PDF page cropping with respect to both visual part and elements (svg, text, etc.) #2579

Answered by JorjMcKie
vkovenko asked this question in Q&A
Discussion options

You must be logged in to vote

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:

  1. Ignore them (leave untouched)
  2. Delete if interscting a redaction
  3. Punch a hole for every redaction annotation intersecting.

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().

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@JorjMcKie
Comment options

Answer selected by vkovenko
@vkovenko
Comment options

@JorjMcKie
Comment options

@JorjMcKie
Comment options

@vkovenko
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants