【问题标题】:how to center allign a text in a custom x y coordinate using reportlab如何使用reportlab在自定义x y坐标中居中对齐文本
【发布时间】:2017-03-30 11:39:52
【问题描述】:

我正在尝试开发一个 python 应用程序。该应用程序应该在 a4 页面上打印文本,并且在该 a4 纸上已经有 4 个矩形框,我必须在每个框中以居中对齐格式放置文本。图片作为参考附上。sample image 我用reportlab写过这样的东西。

self.canvas = canvas.Canvas(name, pagesize=landscape(A4))
self.canvas.drawCentredString(x1,y1,"c1")

但我没有实现我的目标。

【问题讨论】:

    标签: python-2.7 reportlab


    【解决方案1】:

    rlhelper 有一些有用的功能,在这里可能会有所帮助。 如果你能识别出每个盒子的中点x坐标,下面的函数就可以工作了:

    导入 rlhelper simpleCentredstring('canvas', 'x', 'y', 'string', 'fontcolor', 'font (+weight)','fontsize')

    【讨论】:

      猜你喜欢
      • 2021-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-20
      • 2021-01-27
      • 2011-06-25
      • 2014-11-19
      • 2021-08-29
      相关资源
      最近更新 更多