diff --git a/TODO.md b/TODO.md index 0a2df64b..f0dccef7 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,8 @@ ## PLAYA 0.2.x - [ ] update `pdfplumber` branch and run `pdfplumber` tests in CI - [ ] make a separate directory for third party tests -- [ ] fix incorrect bboxes when rotation/skewing is applied (performance hit...) +- [x] fix incorrect bboxes when rotation is applied +- [x] return more useful names for custom colorspaces/patterns - [ ] `decode_text` is remarkably slow - [ ] `render_char` and `render_string` are also quite slow - [ ] remove the rest of the meaningless abuses of `cast` diff --git a/playa/page.py b/playa/page.py index e2677e4d..5a0473a7 100644 --- a/playa/page.py +++ b/playa/page.py @@ -1419,10 +1419,10 @@ def make_path( linewidth=gstate.linewidth, dash_pattern=gstate.dash.dash, dash_phase=gstate.dash.phase, - stroking_colorspace=str(gstate.scs), + stroking_colorspace=gstate.scs.name, stroking_color=gstate.scolor.values, stroking_pattern=gstate.scolor.pattern, - non_stroking_colorspace=str(gstate.ncs), + non_stroking_colorspace=gstate.ncs.name, non_stroking_color=gstate.ncolor.values, non_stroking_pattern=gstate.ncolor.pattern, ) @@ -1604,10 +1604,10 @@ def render_char( render_mode=self.textstate.render_mode, dash_pattern=self.graphicstate.dash.dash, dash_phase=self.graphicstate.dash.phase, - stroking_colorspace=str(self.graphicstate.scs), + stroking_colorspace=self.graphicstate.scs.name, stroking_color=self.graphicstate.scolor.values, stroking_pattern=self.graphicstate.scolor.pattern, - non_stroking_colorspace=str(self.graphicstate.ncs), + non_stroking_colorspace=self.graphicstate.ncs.name, non_stroking_color=self.graphicstate.ncolor.values, non_stroking_pattern=self.graphicstate.ncolor.pattern, mcid=None if self.mcs is None else self.mcs.mcid, diff --git a/playa/utils.py b/playa/utils.py index 22b147fe..13d38cdd 100644 --- a/playa/utils.py +++ b/playa/utils.py @@ -273,6 +273,14 @@ def get_transformed_bound(matrix: Matrix, bbox: Rect) -> Rect: """Transform a bounding box and return the rectangle that covers the points of the resulting shape.""" x0, y0, x1, y1 = bbox + # No rotation involved, corners are still valid. FIXME: proof + if matrix[1] >= 0 and matrix[2] >= 0: + return get_bound( + ( + apply_matrix_pt(matrix, (x0, y0)), + apply_matrix_pt(matrix, (x1, y1)), + ) + ) return get_bound( ( apply_matrix_pt(matrix, (x0, y0)),