本文整理汇总了Python中reportlab.platypus.paragraph.Paragraph.breakLines方法的典型用法代码示例。如果您正苦于以下问题:Python Paragraph.breakLines方法的具体用法?Python Paragraph.breakLines怎么用?Python Paragraph.breakLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.paragraph.Paragraph
的用法示例。
在下文中一共展示了Paragraph.breakLines方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _draw_tyvek
# 需要导入模块: from reportlab.platypus.paragraph import Paragraph [as 别名]
# 或者: from reportlab.platypus.paragraph.Paragraph import breakLines [as 别名]
def _draw_tyvek(p, inventory):
p.line(15, 245, 345, 245)
p.line(15, 188, 345, 188)
p.line(15, 115, 345, 115)
p.setFontSize(12)
p.drawString(26, 290, 'DC-%0.3d' % inventory.dropship.id)
p.drawString(295, 290, str(inventory.item.id))
if len(inventory.item.name) > 55:
p.setFont('Helvetica-Bold', 8)
else:
p.setFont('Helvetica-Bold', 10)
p.drawString(26, 260, ellipsize(inventory.item.name, 75))
p.setFont('Helvetica-Bold', 10)
p.drawString( 26, 224, 'Console:')
p.drawString(120, 224, inventory.item.category.name)
p.drawString( 26, 200, 'Rating:')
p.drawString(120, 200, inventory.item.rating.title)
p.drawImage(inventory.item.rating.image.path, 211, 197, width=20, height=30)
p.setFont('Helvetica', 10)
styles = getSampleStyleSheet()
para = Paragraph(ellipsize(inventory.item.description, 305), styles['Normal'])
para.wrap(290, 10000)
i = 0
ll = para.breakLines(290)
for l in ll.lines:
if ll.kind == 0:
p.drawString(25, 170 - i, ' '.join(l[1]))
else:
p.drawString(25, 170 - i, ' '.join([x.text for x in l.words]))
i += 10
from code128 import Code128
bar = Code128()
image = bar.getImage(inventory.barcode, 50, "png")
_fd, n = tempfile.mkstemp()
image.save(n, "PNG")
p.drawImage(n, 196, 60, width=140, height=50)
p.setFont('Helvetica-Bold', 10)
p.drawString(236, 50, inventory.barcode)
p.drawImage(
os.path.join(settings.STATIC_ROOT, "img/bw-logo.png"),
26, 80, width=87, height=22)
p.setFont('Helvetica-Bold', 10)
p.drawString(25, 70, 'PO Box 6487')
p.drawString(25, 58, 'Delray Beach, FL 33482-9901')
p.showPage()