MCPcopy Index your code
hub / github.com/clips/pattern / render

Method render

pattern/web/pdf/converter.py:433–491  ·  view source on GitHub ↗
(item)

Source from the content-addressed store, hash-verified

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):
480 self.outfp.write('<text>%s</text>\n' % item.get_text())
481 elif isinstance(item, LTImage):
482 if self.outdir:
483 name = self.write_image(item)
484 self.outfp.write('<image src="%s" width="%d" height="%d" />\n' %
485 (enc(name), item.width, item.height))
486 else:
487 self.outfp.write('<image width="%d" height="%d" />\n' %
488 (item.width, item.height))
489 else:
490 assert 0, item

Callers

nothing calls this directly

Calls 8

write_textMethod · 0.95
bbox2strFunction · 0.90
encFunction · 0.90
writeMethod · 0.80
get_ptsMethod · 0.80
write_imageMethod · 0.80
renderFunction · 0.50
get_textMethod · 0.45

Tested by

no test coverage detected