Search code examples
reportlab

when reportlab draw a long string, how to auto wrap?


long_line = '''
xhtml2pdf is a html2pdf converter using the ReportLab Toolkit, the HTML5lib and pyPdf. It supports HTML 5 and CSS 2.1 (and some of CSS 3). It is completely written in pure Python so it is platform independent.
'''
can.drawString(0, 700, long_line) 

The string is too long, so not all of it can show in the pdf page, how to auto-wrap it?


Solution

  • If you want auto wrapping you are probably best off using Platypus or RML with ReportLab. If you draw directly on the canvas you will have to manage string wrapping yourself.