gpt4 book ai didi

python - 如何摆脱 SimpleDocTemplate() 中的间距。 Python。报告实验室

转载 作者:行者123 更新时间:2023-12-01 22:44:53 27 4
gpt4 key购买 nike

有人知道当我使用 SimpleDocTemplate() 制作 PDF 文档时是否可以删除默认间距。

我希望它从一个角打印到另一个角。

   response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'

# Our container for 'Flowable' objects
elements = []

# A large collection of style sheets pre-made for us
styles = getSampleStyleSheet()

# A basic document for us to write to 'rl_hello_table.pdf'
doc = SimpleDocTemplate(response)

# elements.append(Paragraph("Wumpus vs Cave Population Report",
# styles['Title']))

data = [
['Deep Ditch', 50],
['Death Gully', 5000],
['Dire Straits', 600],
['Deadly Pit', 5],
['Deep Ditch', 50],
['Deep Ditch', 50],
['Death Gully', 5000],
['Dire Straits', 600],
['Deadly Pit', 5],
['Deep Ditch', 50],
]

# Create the table with the necessary style, and add it to the
# elements list.
table = Table(data, colWidths=270, rowHeights=70)
elements.append(table)

# Write the document to response
doc.build(elements)

return response

最佳答案

尝试:

doc = SimpleDocTemplate(response, rightMargin=0, leftMargin=0, topMargin=0, bottomMargin=0)

关于python - 如何摆脱 SimpleDocTemplate() 中的间距。 Python。报告实验室,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3374296/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com