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

Method parse_borders

pdf2docx/table/TableStructure.py:44–58  ·  view source on GitHub ↗

Parse cell borders from strokes. Args: h_strokes (dict): A dict of y-coordinate v.s. horizontal strokes, e.g. ``{y0: [h1,h2,..], y1: [h3,h4,...]}`` v_strokes (dict): A dict of x-coordinates v.s. vertical strokes, e.g. ``{x0:

(self, h_strokes:dict, v_strokes:dict)

Source from the content-addressed store, hash-verified

42
43
44 def parse_borders(self, h_strokes:dict, v_strokes:dict):
45 '''Parse cell borders from strokes.
46
47 Args:
48 h_strokes (dict): A dict of y-coordinate v.s. horizontal strokes, e.g.
49 ``{y0: [h1,h2,..], y1: [h3,h4,...]}``
50 v_strokes (dict): A dict of x-coordinates v.s. vertical strokes, e.g.
51 ``{x0: [v1,v2,..], x1: [v3,v4,...]}``
52 '''
53 x0, y0, x1, y1 = self.merged_bbox
54 top = self._get_border_stroke(h_strokes[y0], 'row')
55 bottom = self._get_border_stroke(h_strokes[y1], 'row')
56 left = self._get_border_stroke(v_strokes[x0], 'col')
57 right = self._get_border_stroke(v_strokes[x1], 'col')
58 self.borders = (top, bottom, left, right)
59
60
61 def parse_shading(self, fills:Shapes):

Callers 1

parseMethod · 0.80

Calls 1

_get_border_strokeMethod · 0.95

Tested by

no test coverage detected