python - How to write at once multiline contents to PDF -
i see, there nice library called reportlab
, makes possible lot of tricks pdf
files in python
. however, exploring many forum threads, see everywhere 1 same pattern of writing pdf line line:
for line in lines: c.drawstring(100, 100, line)
it not well. better, if write pdf right away, without having clone loop throughout code. something, like
c.methodname(10, 10, multiline_contents)
the draw string methods draw single lines of text on canvas. text object interface provides detailed control of text layout parameters not available directly @ canvas level. in addition, results in smaller pdf render faster many separate calls drawstring methods.
something following snippet should work multiline text printing.
def your_function: #canvas canvas object instance. textobject = canvas.begintext() line in multiline: textobject.textline(line) canvas.drawtext(textobject)
you can find more information related drawing methods here.
Comments
Post a Comment