我有一个文本块,它是从数据库中动态提取的,在被服务给用户之前放在PDF中。文本被放置在有线条的背景上,就像记事本一样。我想将文本隔开,以便在每个背景行之间只有一行文本。
我能够使用以下代码在段落之间创建垂直间距(用于生成PDF的另一部分)。
style = getSampleStyleSheet()['Normal']
style.fontName = 'Helvetica'
style.spaceAfter = 15
style.alignment = TA_JUSTIFY
story = [Paragraph(choice.value,style) for choice in chain(context['question1'].itervalues(),context['question2'].itervalues())]
generated_file = StringIO()
frame1 = Frame(50,100,245,240, showBoundary=0)
frame2 = Frame(320,100,245,240, showBoundary=0)
page_template = PageTemplate(frames=[frame1,frame2])
doc = BaseDocTemplate(generated_file,pageTemplates=[page_template])
doc.build(story)
但是,这里不起作用,因为我只有一个大段落。
很确定你想改变的是领先。从第6章的用户手册。
前导的定义见第2章:
因此,尝试不同的前导值,例如:
添加前导到段落样式
生成PDF
结果
相关问题 更多 >
编程相关推荐