MCPcopy Create free account
hub / github.com/clips/pattern / receive_layout

Method receive_layout

pattern/web/pdf/converter.py:422–493  ·  view source on GitHub ↗
(self, ltpage)

Source from the content-addressed store, hash-verified

420 return
421
422 def receive_layout(self, ltpage):
423 def show_group(item):
424 if isinstance(item, LTTextBox):
425 self.outfp.write('<textbox id="%d" bbox="%s" />\n' %
426 (item.index, bbox2str(item.bbox)))
427 elif isinstance(item, LTTextGroup):
428 self.outfp.write('<textgroup bbox="%s">\n' % bbox2str(item.bbox))
429 for child in item:
430 show_group(child)
431 self.outfp.write('</textgroup>\n')
432 return
433 def render(item):
434 if isinstance(item, LTPage):
435 self.outfp.write('<page id="%s" bbox="%s" rotate="%d">\n' %
436 (item.pageid, bbox2str(item.bbox), item.rotate))
437 for child in item:
438 render(child)
439 if item.groups is not None:
440 self.outfp.write('<layout>\n')
441 for group in item.groups:
442 show_group(group)
443 self.outfp.write('</layout>\n')
444 self.outfp.write('</page>\n')
445 elif isinstance(item, LTLine):
446 self.outfp.write('<line linewidth="%d" bbox="%s" />\n' %
447 (item.linewidth, bbox2str(item.bbox)))
448 elif isinstance(item, LTRect):
449 self.outfp.write('<rect linewidth="%d" bbox="%s" />\n' %
450 (item.linewidth, bbox2str(item.bbox)))
451 elif isinstance(item, LTCurve):
452 self.outfp.write('<curve linewidth="%d" bbox="%s" pts="%s"/>\n' %
453 (item.linewidth, bbox2str(item.bbox), item.get_pts()))
454 elif isinstance(item, LTFigure):
455 self.outfp.write('<figure name="%s" bbox="%s">\n' %
456 (item.name, bbox2str(item.bbox)))
457 for child in item:
458 render(child)
459 self.outfp.write('</figure>\n')
460 elif isinstance(item, LTTextLine):
461 self.outfp.write('<textline bbox="%s">\n' % bbox2str(item.bbox))
462 for child in item:
463 render(child)
464 self.outfp.write('</textline>\n')
465 elif isinstance(item, LTTextBox):
466 wmode = ''
467 if isinstance(item, LTTextBoxVertical):
468 wmode = ' wmode="vertical"'
469 self.outfp.write('<textbox id="%d" bbox="%s"%s>\n' %
470 (item.index, bbox2str(item.bbox), wmode))
471 for child in item:
472 render(child)
473 self.outfp.write('</textbox>\n')
474 elif isinstance(item, LTChar):
475 self.outfp.write('<text font="%s" bbox="%s" size="%.3f">' %
476 (enc(item.fontname), bbox2str(item.bbox), item.size))
477 self.write_text(item.get_text())
478 self.outfp.write('</text>\n')
479 elif isinstance(item, LTText):

Callers

nothing calls this directly

Calls 1

renderFunction · 0.50

Tested by

no test coverage detected