pdf_form_display.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:intake 作者: codeforamerica 项目源码 文件源码
def draw_paragraph(self, text, max_width, max_height, style):
        if not text:
            text = ''
        if not isinstance(text, str):
            text = str(text)
        text = text.strip(string.whitespace)
        text = text.replace('\n', "<br/>")
        p = Paragraph(text, style)
        used_width, used_height = p.wrap(max_width, max_height)
        line_widths = p.getActualLineWidths0()
        number_of_lines = len(line_widths)
        if number_of_lines > 1:
            actual_width = used_width
        elif number_of_lines == 1:
            actual_width = min(line_widths)
            used_width, used_height = p.wrap(actual_width + 0.1, max_height)
        else:
            return 0, 0
        p.drawOn(self.canvas, self.cursor.x, self.cursor.y - used_height)
        return used_width, used_height
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号