我在python 2.7中使用了reportlab 3.1.44 以下是在表格中使用段落的代码。
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()
字体很大时有2个问题。
如何解决此问题?