当前位置: 首页>>代码示例>>Python>>正文


Python ParagraphStyle.wordWrap方法代码示例

本文整理汇总了Python中reportlab.lib.styles.ParagraphStyle.wordWrap方法的典型用法代码示例。如果您正苦于以下问题:Python ParagraphStyle.wordWrap方法的具体用法?Python ParagraphStyle.wordWrap怎么用?Python ParagraphStyle.wordWrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.lib.styles.ParagraphStyle的用法示例。


在下文中一共展示了ParagraphStyle.wordWrap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test3

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import wordWrap [as 别名]
 def test3(self):
     '''compare CJK splitting in some edge cases'''
     from reportlab.pdfgen.canvas import Canvas
     from reportlab.platypus.paragraph import Paragraph
     from reportlab.lib.styles import ParagraphStyle
     from reportlab.pdfbase import pdfmetrics
     from reportlab.lib.enums import TA_LEFT
     sty = ParagraphStyle('A')
     sty.fontSize = 15
     sty.leading = sty.fontSize*1.2
     sty.fontName = 'Courier'
     sty.alignment = TA_LEFT
     sty.wordWrap = 'CJK'
     p0=Paragraph('ABCDEFGHIJKL]N',sty)
     p1=Paragraph('AB<font color="red">C</font>DEFGHIJKL]N',sty)
     canv = Canvas('test_platypus_paragraph_cjk3.pdf')
     ix = len(canv._code)
     aW = pdfmetrics.stringWidth('ABCD','Courier',15)
     w,h=p0.wrap(aW,1000000)
     y = canv._pagesize[1]-72-h
     p0.drawOn(canv,72,y)
     w,h=p1.wrap(aW,1000000)
     y -= h+10
     p1.drawOn(canv,72,y)
     w,h=p0.wrap(aW*0.25-2,1000000)
     y -= h+10
     p0.drawOn(canv,72,y)
     w,h=p1.wrap(aW/4.-2,1000000)
     y -= h+10
     p1.drawOn(canv,72,y)
     assert canv._code[ix:]==['q', '1 0 0 1 72 697.8898 cm', 'q', '0 0 0 rg', 'BT 1 0 0 1 0 57 Tm /F2 15 Tf 18 TL (ABCD) Tj T* (EFGH) Tj T* (IJKL]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 615.8898 cm', 'q', 'BT 1 0 0 1 0 57 Tm 18 TL /F2 15 Tf 0 0 0 rg (AB) Tj 1 0 0 rg (C) Tj 0 0 0 rg (D) Tj T* (EFGH) Tj T* (IJKL]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 353.8898 cm', 'q', '0 0 0 rg', 'BT 1 0 0 1 0 237 Tm /F2 15 Tf 18 TL (A) Tj T* (B) Tj T* (C) Tj T* (D) Tj T* (E) Tj T* (F) Tj T* (G) Tj T* (H) Tj T* (I) Tj T* (J) Tj T* (K) Tj T* (L) Tj T* (]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 91.88976 cm', 'q', 'BT 1 0 0 1 0 237 Tm 18 TL /F2 15 Tf 0 0 0 rg (A) Tj T* (B) Tj T* 1 0 0 rg (C) Tj T* 0 0 0 rg (D) Tj T* (E) Tj T* (F) Tj T* (G) Tj T* (H) Tj T* (I) Tj T* (J) Tj T* (K) Tj T* (L) Tj T* (]) Tj T* (N) Tj T* ET', 'Q', 'Q']
     canv.showPage()
     canv.save()
开发者ID:Jbaumotte,项目名称:web2py,代码行数:35,代码来源:test_platypus_paragraphs.py

示例2: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import wordWrap [as 别名]
    def toParagraphStyle(self, first):
        style = ParagraphStyle('default%d' % self.UID(), keepWithNext=first.keepWithNext)
        style.fontName = first.fontName
        style.fontSize = first.fontSize
        style.letterSpacing = first.letterSpacing
        style.leading = max(first.leading + first.leadingSpace, first.fontSize * 1.25)
        style.backColor = first.backColor
        style.spaceBefore = first.spaceBefore
        style.spaceAfter = first.spaceAfter
        style.leftIndent = first.leftIndent
        style.rightIndent = first.rightIndent
        style.firstLineIndent = first.firstLineIndent
        style.textColor = first.textColor
        style.alignment = first.alignment
        style.bulletFontName = first.bulletFontName or first.fontName
        style.bulletFontSize = first.fontSize
        style.bulletIndent = first.bulletIndent
        style.wordWrap = first.wordWrap

        # Border handling for Paragraph

        # Transfer the styles for each side of the border, *not* the whole
        # border values that reportlab supports. We'll draw them ourselves in
        # PmlParagraph.
        style.borderTopStyle = first.borderTopStyle
        style.borderTopWidth = first.borderTopWidth
        style.borderTopColor = first.borderTopColor
        style.borderBottomStyle = first.borderBottomStyle
        style.borderBottomWidth = first.borderBottomWidth
        style.borderBottomColor = first.borderBottomColor
        style.borderLeftStyle = first.borderLeftStyle
        style.borderLeftWidth = first.borderLeftWidth
        style.borderLeftColor = first.borderLeftColor
        style.borderRightStyle = first.borderRightStyle
        style.borderRightWidth = first.borderRightWidth
        style.borderRightColor = first.borderRightColor

        # If no border color is given, the text color is used (XXX Tables!)
        if (style.borderTopColor is None) and style.borderTopWidth:
            style.borderTopColor = first.textColor
        if (style.borderBottomColor is None) and style.borderBottomWidth:
            style.borderBottomColor = first.textColor
        if (style.borderLeftColor is None) and style.borderLeftWidth:
            style.borderLeftColor = first.textColor
        if (style.borderRightColor is None) and style.borderRightWidth:
            style.borderRightColor = first.textColor

        style.borderPadding = first.borderPadding

        style.paddingTop = first.paddingTop
        style.paddingBottom = first.paddingBottom
        style.paddingLeft = first.paddingLeft
        style.paddingRight = first.paddingRight
        style.fontName = tt2ps(first.fontName, first.bold, first.italic)

        return style
开发者ID:AntycSolutions,项目名称:xhtml2pdf,代码行数:58,代码来源:context.py


注:本文中的reportlab.lib.styles.ParagraphStyle.wordWrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。