Static position of text and QR

北城以北 提交于 2020-01-16 11:56:13

问题


I am new to reportlab pdf creation and I want to know how to provide a static position for a QR image i.e. x = 0 and y = 0, height and width 50 points.

this is my code:

pdfmetrics.registerFont(TTFont("Vera", "Vera.ttf"))
pdfmetrics.registerFont(TTFont("Vera-Bold", "VeraBd.ttf"))
doc = SimpleDocTemplate("form.pdf", pagesize=(3.93*inch, 5.77*inch), rightMargin=0,leftMargin=0, topMargin=1.67*inch, bottomMargin=0.77*inch)
Story=[]

styles=getSampleStyleSheet()
styles.add(ParagraphStyle(name='Center', leading = 20, alignment=TA_CENTER))
Story.append(Spacer(1, 10))
ptext = '<font size=16 face=Vera-Bold>Sankettt Rayyy Sankett Rayy Sanket Ray Sanket Ray</font>'

Story.append(Paragraph(ptext, styles["Center"]))
Story.append(Spacer(1, 10))
ptext = '<font size=14 face=Vera>Co-Founder</font>'
Story.append(Paragraph(ptext, styles["Center"]))

ptext = '<font size=14 face=Vera>Fanrex</font>'
Story.append(Paragraph(ptext, styles["Center"]))
Story.append(Spacer(1, 20))

qrCcode = qr.QrCodeWidget("10")
bounds = qrCcode.getBounds()
qrWidth = bounds[2] - bounds[0]
qrHeight = bounds[3] - bounds[1]
width = float(50)
drawing = Drawing(width, width, transform=[width/qrWidth, 0, 0, width/qrHeight, 20, 0])
drawing.add(qrCcode)
Story.append(drawing)

doc.build(Story)

According to my code, the QR starts from where my text ends... I understand its because of the append method. Is there any way to fix it at the bottom left corner, maybe with some padding?

来源:https://stackoverflow.com/questions/59032495/static-position-of-text-and-qr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!