MCPcopy
hub / github.com/ArtifexSoftware/pdf2docx / update_bbox

Method update_bbox

pdf2docx/shape/Shape.py:180–216  ·  view source on GitHub ↗

Update stroke bbox (related to real page CS). * Update start/end points if ``rect.area==0``. * Ppdate bbox directly if ``rect.area!=0``. Args: rect (fitz.Rect, tuple): ``(x0, y0, x1, y1)`` like data. Returns: Stroke: self

(self, rect)

Source from the content-addressed store, hash-verified

178
179
180 def update_bbox(self, rect):
181 '''Update stroke bbox (related to real page CS).
182
183 * Update start/end points if ``rect.area==0``.
184 * Ppdate bbox directly if ``rect.area!=0``.
185
186 Args:
187 rect (fitz.Rect, tuple): ``(x0, y0, x1, y1)`` like data.
188
189 Returns:
190 Stroke: self
191 '''
192 rect = fitz.Rect(rect)
193
194 # an empty area line
195 if rect.get_area()==0.0:
196 self._start = fitz.Point(rect[0:2])
197 self._end = fitz.Point(rect[2:])
198 super().update_bbox(self._to_rect())
199
200 # a rect
201 else:
202 super().update_bbox(rect)
203
204 # horizontal stroke
205 if rect.width >= rect.height:
206 y = (rect.y0+rect.y1)/2.0
207 self._start = fitz.Point(rect.x0, y)
208 self._end = fitz.Point(rect.x1, y)
209
210 # vertical stroke
211 else:
212 x = (rect.x0+rect.x1)/2.0
213 self._start = fitz.Point(x, rect.y0)
214 self._end = fitz.Point(x, rect.y1)
215
216 return self
217
218 @property
219 def default_type(self):

Callers 15

_create_sectionMethod · 0.45
restoreMethod · 0.45
sub_lineMethod · 0.45
from_imageMethod · 0.45
stream_tablesMethod · 0.45
to_strokeMethod · 0.45
finalizeMethod · 0.45
parse_shadingMethod · 0.45
to_table_blockMethod · 0.45
_group_h_v_strokesMethod · 0.45

Calls 1

_to_rectMethod · 0.95

Tested by

no test coverage detected