Skip to content

get_drawings() is no coordinate show width and height #1065

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

You must be logged in to vote

I suppose you have figured out how to locate curves and other stuff in the output of page.get_drawings().

  1. get_drawings() is a list of Python dicts.
  2. Each dict (called a "path") is a list of elementary drawings (lines, curves, rectangles) accompanied by a number of shared properties.
  3. Among those path properties is "rect" which is the rectangle wrapping the complete path.
  4. To compute the rectangle of a single curve within a path, simply do this:
# a curve is a tuple ("c", p1, p2, p3, p4). The items after the "c" are points
r = fitz.Rect(p1, p1)
r |= p2
r |= p3
r |= p4
# now 'r' is the rectangle wrapping that curve. Take its width / height

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JorjMcKie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1064 on May 30, 2021 13:02.