1

How do I find the baseline for a line of text in Reportlab so I can align other elements on the page with the baseline of the text? I am using canvas.drawString() for these elements.

4

1 に答える 1

0

キャンバスは、既定ではページの左下隅にある (0,0) 原点を持つデカルト (X,Y) 座標を使用して識別されるシート上のポイントを持つ 1 枚の白い紙と考える必要があります。

さらに、デフォルトでは、最初の座標 x は右に移動し、2 番目の座標 y は上に移動します。

x 座標と y 座標がわかれば、何でも整列できます。

from reportlab.pdfgen import canvas

def hello(c):
    c.drawString(100,100, "x=100,y=100")
    c.drawString(200,200, "x=200,y=200")

c = canvas.Canvas("hello.pdf")
hello(c)
c.showPage()
c.save()
于 2013-03-14T08:53:45.593 に答える