Detect regions with different backgrounds #1687
-
Hello, suppose there is a PDF page containing a column with some background color different from the main white background. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello, there is method This are only slightly different if the background was not created by PDF drawings but by embedded images (which is rare). |
Beta Was this translation helpful? Give feedback.
Hello, there is method
page.get_drawings()
which returns lines, rectangles, curves together with any fill colors.So you can look for a rectangle in that list of dictionaries. In your case it should indeed have a fill color and be large enough, etc.
Then take that rect as the clip parameter in
page.get_text(option, clip=rect, ...more args)
.This are only slightly different if the background was not created by PDF drawings but by embedded images (which is rare).