0
我在python 2.7中使用reportlab 3.1.44 這是在表中使用段落的代碼。reportlab行間距和表中段落的擬合
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.rl_config import defaultPageSize
from reportlab.lib.units import inch
from reportlab.lib.styles import ParagraphStyle
from reportlab.platypus.tables import Table, TableStyle
from reportlab.lib import colors
from reportlab.lib.colors import Color
styles = getSampleStyleSheet()
def make_report():
doc = SimpleDocTemplate("hello.pdf")
story = []
style = styles["Normal"]
ps = ParagraphStyle('title', fontSize=20)
p1 = "here is some paragraph to see in large font"
data = []
table_row = [Paragraph(p1, ps),\
Paragraph(p1, ps)\
]
data.append(table_row)
t1 = Table(data)
t1.setStyle(TableStyle([\
('GRID', (0,0), (-1,-1), 0.25, colors.red, None, (2,2,1)),\
]))
story.append(t1)
doc.build(story)
if __name__ == "__main__":
make_report()
這是字體較大時的兩個問題。
- 文本較大的電池,以便它超越國界
- 的間距行間太小
我怎樣才能解決這個問題?
大。效果很好。謝謝。 – max