【问题标题】:Positioning MultiCell with fpdf to the right side of the pdf document使用 fpdf 将 MultiCell 定位到 pdf 文档的右侧
【发布时间】:2020-06-23 23:32:58
【问题描述】:

给定

pdf.multi_cell(189, 10, text = "asdasdasdasd")

我知道这是宽度=180,高度=10,然后是文本。我想把这个单元格放在我的 pdf 文档的右侧,标准是放在左侧。是否可以在 x 轴上移动 multi_cell?对齐只是对齐单元格内的文本,这没有帮助。感谢您对此的帮助! :)

【问题讨论】:

    标签: python python-3.x pdf-generation fpdf


    【解决方案1】:

    在这个来自Creating Pdfs 的示例中,您可以看到如何在要向右移动的真实单元格的左侧创建一个虚拟间隔单元格,其中左侧虚拟间隔单元格的宽度将用于推动真正的右侧单元格在您指定的右侧:

        # Add an address
        self.cell(100) # Pushes next cell to right by 100 mm
        self.cell(0, 5, 'Mike Wyzowsky', ln=1)
        self.cell(100) # Pushes next cell to right by 100 mm
        self.cell(0, 5, '123 American Way', ln=1)
        self.cell(100) # Pushes next cell to right by 100 mm
        self.cell(0, 5, 'Any Town, USA', ln=1)
    

    【讨论】:

    • 也可以使用set_x()。
    • @Olivier 是什么意思?我该如何使用它?
    • 参见here 以获取使用 set_x() 的示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 1970-01-01
    • 2012-11-13
    • 2013-12-29
    • 2013-03-01
    相关资源
    最近更新 更多