我有一个Table
有两个细胞,每个细胞里面都有一个Paragraph
from reportlab.platypus import Paragraph, Table, TableStyle
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.units import cm
table_style_footer = TableStyle(
[
('LEFTPADDING', (0, 0), (-1, -1), 0),
('RIGHTPADDING', (0, 0), (-1, -1), 0),
('TOPPADDING', (0, 0), (-1, -1), 0),
('BOTTOMPADDING', (0, 0), (-1, -1), 0),
('BOX', (0, 0), (-1, -1), 1, (0, 0, 0)),
('VALIGN', (0, 0), (-1, -1), 'TOP'),
]
)
style_p_footer = ParagraphStyle('Normal')
style_p_footer.fontName = 'Arial'
style_p_footer.fontSize = 8
style_p_footer.leading = 10
Table([
[
Paragraph('Send To:', style_p_footer),
Paragraph('Here should be a variable with long content', style_p_footer)
]
],
[1.7 * cm, 4.8 * cm],
style=table_style_footer
)
我需要隐藏段落的溢出内容,但是段落而不是隐藏溢出内容做了一个换行符。在
Reportlab似乎不支持隐藏溢出,但是我们可以通过使用
Paragraph
的breakLines
函数来实现它。breakLines
函数返回一个对象,该对象包含给定宽度的段落的所有行,因此我们也可以使用它来查找第一行并丢弃其他所有行。在基本上我们需要做的是:
在代码中执行此操作如下所示:
相关问题 更多 >
编程相关推荐