diff --git a/pdfminer/layout.py b/pdfminer/layout.py index 99807b2..7037fe7 100644 --- a/pdfminer/layout.py +++ b/pdfminer/layout.py @@ -81,14 +81,15 @@ class LTComponent(LTItem): return ('<%s %s>' % (self.__class__.__name__, bbox2str(self.bbox))) - def set_bbox(self, (x0, y0, x1, y1)): + def set_bbox(self, bbox): + (x0, y0, x1, y1) = bbox self.x0 = x0 self.y0 = y0 self.x1 = x1 self.y1 = y1 self.width = x1-x0 self.height = y1-y0 - self.bbox = (x0, y0, x1, y1) + self.bbox = bbox return def is_empty(self): @@ -158,7 +159,8 @@ class LTLine(LTCurve): ## class LTRect(LTCurve): - def __init__(self, linewidth, (x0, y0, x1, y1)): + def __init__(self, linewidth, bbox): + (x0, y0, x1, y1) = bbox LTCurve.__init__(self, linewidth, [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]) return diff --git a/pdfminer/pdfdevice.py b/pdfminer/pdfdevice.py index 15fe80a..f6506f4 100644 --- a/pdfminer/pdfdevice.py +++ b/pdfminer/pdfdevice.py @@ -79,8 +79,9 @@ class PDFTextDevice(PDFDevice): scaling, charspace, wordspace, rise, dxscale) return - def render_string_horizontal(self, seq, matrix, (x, y), + def render_string_horizontal(self, seq, matrix, pos, font, fontsize, scaling, charspace, wordspace, rise, dxscale): + (x, y) = pos needcharspace = False for obj in seq: if isnumber(obj): @@ -97,8 +98,9 @@ class PDFTextDevice(PDFDevice): needcharspace = True return (x, y) - def render_string_vertical(self, seq, matrix, (x, y), + def render_string_vertical(self, seq, matrix, pos, font, fontsize, scaling, charspace, wordspace, rise, dxscale): + (x, y) = pos needcharspace = False for obj in seq: if isnumber(obj): diff --git a/pdfminer/utils.py b/pdfminer/utils.py index f83f6cf..80c735c 100644 --- a/pdfminer/utils.py +++ b/pdfminer/utils.py @@ -54,25 +54,33 @@ def apply_png_predictor(pred, colors, columns, bitspercomponent, data): MATRIX_IDENTITY = (1, 0, 0, 1, 0, 0) -def mult_matrix((a1, b1, c1, d1, e1, f1), (a0, b0, c0, d0, e0, f0)): +def mult_matrix(m1, m0): + (a1, b1, c1, d1, e1, f1) = m1 + (a0, b0, c0, d0, e0, f0) = m0 """Returns the multiplication of two matrices.""" return (a0*a1+c0*b1, b0*a1+d0*b1, a0*c1+c0*d1, b0*c1+d0*d1, a0*e1+c0*f1+e0, b0*e1+d0*f1+f0) -def translate_matrix((a, b, c, d, e, f), (x, y)): +def translate_matrix(m, v): """Translates a matrix by (x, y).""" + (a, b, c, d, e, f) = m + (x, y) = v return (a, b, c, d, x*a+y*c+e, x*b+y*d+f) -def apply_matrix_pt((a, b, c, d, e, f), (x, y)): +def apply_matrix_pt(m, v): + (a, b, c, d, e, f) = m + (x, y) = v """Applies a matrix to a point.""" return (a*x+c*y+e, b*x+d*y+f) -def apply_matrix_norm((a, b, c, d, e, f), (p, q)): +def apply_matrix_norm(m, v): """Equivalent to apply_matrix_pt(M, (p,q)) - apply_matrix_pt(M, (0,0))""" + (a, b, c, d, e, f) = m + (p, q) = v return (a*p+c*q, b*p+d*q) @@ -227,11 +235,13 @@ def enc(x, codec='ascii'): return x.encode(codec, 'xmlcharrefreplace') -def bbox2str((x0, y0, x1, y1)): +def bbox2str(bbox): + (x0, y0, x1, y1) = bbox return '%.3f,%.3f,%.3f,%.3f' % (x0, y0, x1, y1) -def matrix2str((a, b, c, d, e, f)): +def matrix2str(m): + (a, b, c, d, e, f) = m return '[%.2f,%.2f,%.2f,%.2f, (%.2f,%.2f)]' % (a, b, c, d, e, f) @@ -264,7 +274,8 @@ class Plane(object): def __contains__(self, obj): return obj in self._objs - def _getrange(self, (x0, y0, x1, y1)): + def _getrange(self, bbox): + (x0, y0, x1, y1) = bbox if (x1 <= self.x0 or self.x1 <= x0 or y1 <= self.y0 or self.y1 <= y0): return x0 = max(self.x0, x0) @@ -306,9 +317,10 @@ class Plane(object): return # find(): finds objects that are in a certain area. - def find(self, (x0, y0, x1, y1)): + def find(self, bbox): + (x0, y0, x1, y1) = bbox done = set() - for k in self._getrange((x0, y0, x1, y1)): + for k in self._getrange(bbox): if k not in self._grid: continue for obj in self._grid[k]: