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


Python ParagraphStyle.leftIndent方法代码示例

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


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

示例1: get_content

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
    def get_content(self, column_data, row_values, col_values):
        """ return the content formated as defined in the constructor or in the column object """
        value = self.value
        
        if value == None or value == False:
            return ""
        
        #should we trunc the text
        if self.truncate_length != None:
            value = c2c_helper.ellipsis(value, self.truncate_length, ellipsis="[...]")

        ps = ParagraphStyle('standard_text')
        ps.fontName = self.get_font(column_data)
        ps.fontSize = self.get_font_size(column_data)
        ps.alignment = self.get_align_code(column_data)

        
        #should we indent the content
        if self.indent != None:
            ps.leftIndent = self.indent * 2 * mm
        elif type(column_data) == TextColData and column_data.indent != None:
            ps.leftIndent = column_data.indent * 2 * mm
        
        p = Paragraph(c2c_helper.encode_entities(value), ps)
        return p
开发者ID:3dfxmadscientist,项目名称:odoo-extra-1,代码行数:27,代码来源:table_elements.py

示例2: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
 def toParagraphStyle(self, first, full=False):
     style = ParagraphStyle('default%d' % self.UID(), keepWithNext=first.keepWithNext)
     style.fontName = first.fontName
     style.fontSize = first.fontSize
     style.leading = max(first.leading, 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
     # Border handling for Paragraph
     style.borderWidth = 0
     if getBorderStyle(first.borderTopStyle):
         style.borderWidth = max(first.borderLeftWidth, first.borderRightWidth, first.borderTopWidth, first.borderBottomWidth)
         style.borderPadding = first.borderPadding # + first.borderWidth
         style.borderColor = first.borderTopColor
         # If no border color is given, the text color is used (XXX Tables!)
         if (style.borderColor is None) and style.borderWidth:
             style.borderColor = first.textColor      
     if full:
         style.fontName = tt2ps(first.fontName, first.bold, first.italic)
     return style       
开发者ID:nbio,项目名称:frnda,代码行数:30,代码来源:pisa_context.py

示例3: _add_Y_items

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
    def _add_Y_items(self):
        """ add Y items labels to the chart (Text and styles). Add also light grid for their lines """

        X_pos = 0
        Y_pos = 3

        # draw the items titles with the right indentation

        for i in self.data.items_order:

            item = self.data.items[i]

            ps = ParagraphStyle("indent")
            ps.fontName = self.DEFAULT_FONT
            ps.fontSize = self.DEFAULT_FONT_SIZE
            ps.leftIndent = item.indent * self.INDENT_SPACE

            p = Paragraph(self._encode_entities(item.label), ps)
            self.table[Y_pos + item.Y_pos][X_pos] = p

            # draw the inner grid for this lines
            start_X = X_pos
            end_X = -1
            start_Y = Y_pos + item.Y_pos
            end_Y = Y_pos + item.Y_pos + item.line_number
            self.styles.append(("LINEABOVE", (start_X, end_Y), (end_X, end_Y), 0.2, "#bbbbbb"))
            self.styles.append(("LINEAFTER", (start_X, start_Y), (end_X, end_Y), 0.2, "#bbbbbb"))

        # line that separate the Y items and the datas
        self.styles.append(("LINEAFTER", (X_pos, Y_pos - 2), (X_pos, -1), 1, colors.black))
开发者ID:dxyuniesky,项目名称:openerp-extra-6.1,代码行数:32,代码来源:timebox_chart.py

示例4: addPara

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
    def addPara(self, force=False):

        # Cleanup the trail
        for frag in reversed(self.fragList):
            frag.text = frag.text.rstrip()
            if frag.text:
                break

        if force or (self.text.strip() and self.fragList):

            # Strip trailing whitespaces
            # for f in self.fragList:
            #    f.text = f.text.lstrip()
            #    if f.text:
            #        break
            # self.fragList[-1].lineBreak = self.fragList[-1].text.rstrip()

            # Update paragraph style by style of first fragment
            first = self.fragBlock
            style = ParagraphStyle("default%d" % self.UID(), keepWithNext=first.keepWithNext)
            style.fontName = first.fontName
            style.fontSize = first.fontSize
            style.leading = max(first.leading, 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.alignment = first.alignment

            style.bulletFontName = first.fontName
            style.bulletFontSize = first.fontSize
            style.bulletIndent = first.bulletIndent

            style.borderWidth = max(
                first.borderLeftWidth, first.borderRightWidth, first.borderTopWidth, first.borderBottomWidth
            )
            style.borderPadding = first.borderPadding  # + first.borderWidth
            style.borderColor = first.borderTopColor
            # borderRadius: None,

            # print repr(self.text.strip()), style.leading, "".join([repr(x.text) for x in self.fragList])

            # print first.leftIndent, first.listStyleType,repr(self.text)

            # Add paragraph to story
            para = PmlParagraph(
                self.text, style, frags=self.fragAnchor + self.fragList, bulletText=copy.copy(first.bulletText)
            )
            para.outline = frag.outline
            para.outlineLevel = frag.outlineLevel
            para.outlineOpen = frag.outlineOpen
            self.addStory(para)

            self.fragAnchor = []
            first.bulletText = None

        self.clearFrag()
开发者ID:ahmedsalman,项目名称:django-project,代码行数:61,代码来源:pisa_context.py

示例5: _content

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
    def _content(self):
        # TODO: move styles somewhere else
        # style for additional information box
        ibs = ParagraphStyle('inputBoxStyle',styles['Message'])
        ibs.fontName = 'Courier'
        ibs.leftIndent = cm
        ibs.spaceBefore = 0.2*cm
        ibs.spaceAfter = 0.5*cm
        # font style for letter subject
        styles['Subject'].fontName = 'Helvetica-Bold'

        content = [
            Paragraph(_("auskunft_subject"), styles['Subject']),
            Paragraph(_("auskunft_greeting"), styles['Greeting']),
            Spacer(0,0.5*cm),
            Paragraph(_("auskunft_question_text"), styles['Message']),
            ListFlowable([
                ListItem(Paragraph(_("auskunft_question_1"),styles['Message'])),
                ListItem(Paragraph(_("auskunft_question_2"),styles['Message'])),
                ListItem(Paragraph(_("auskunft_question_3"),styles['Message'])),
                ListItem(Paragraph(_("auskunft_question_4"),styles['Message'])),
                ],
                bulletType='bullet',
                start='square'
            ),
            Paragraph(_("auskunft_reference"), styles['Message']),
            Paragraph(_("auskunft_par_10"), styles['Message']),
            Paragraph(_("auskunft_par_4"), styles['Message']),
            Paragraph(_("auskunft_par_12"), styles['Message']),

            Paragraph(_("auskunft_standard_application"), styles['Message'])
        ]

        # Registered Applications
        if self.table_apps:
            content += [
                Paragraph(_("auskunft_registered_application_pre"),styles['Message']),
                self.table_apps,
                Paragraph(_("auskunft_registered_application_post"),styles['Message'])
            ]

        # Additional Information
        if self.add_info:
            content += [
                Paragraph(_("auskunft_additional_info_text"), styles['Message']),
                Paragraph(self.add_info,ibs)
            ]

        content += [
            Paragraph(_("auskunft_method_identity"),styles['Message']),
            Paragraph(_("auskunft_expected_response"),styles['Message']),

            Spacer(0,0.5*cm),
            Paragraph(_("auskunft_signature"),styles['Signature']),
            Spacer(0,1.5*cm),
            Paragraph(self.sender_name,styles['Signature'])
        ]

        return content
开发者ID:n0g,项目名称:auskunftsbegehren_at,代码行数:61,代码来源:informationrequest.py

示例6: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [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

示例7: insert_line

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
def insert_line(text, margin=0, size=12, color=black):
    global ACTUAL_LINE
    s = ParagraphStyle('my_style')
    s.textColor = color
    s.fontSize = size
    s.fontName = "Helvetica"
    s.leftIndent = margin
    lines = simpleSplit(text, "Helvetica", size, aW - 25 * mm)
    for line in lines:
        p = Paragraph(line, s)
        p.wrapOn(pdf_file, aW, aH)
        p.drawOn(pdf_file, 10 * mm, ACTUAL_LINE * mm)
        ACTUAL_LINE -= 9
开发者ID:caiojuvino,项目名称:report,代码行数:15,代码来源:report_generator.py

示例8: end_page_infos_building

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
def end_page_infos_building(content, styles):
    content.append(BIG_INTER_LINE)
    p = ParagraphStyle('info')
    p.fontSize = 10
    p.alignment = TA_LEFT
    content.append(Paragraph("Please return this document to the administrative office of the program administrator" , p))
    content.append(BIG_INTER_LINE)
    p_signature = ParagraphStyle('info')
    p_signature.fontSize = 10
    p_signature.leftIndent = 330
    P = Paragraph('''
                    <font size=10>%s ....................................</font>
                    <br/>
                    <font size=10>%s ..../..../........</font>
                    <br/>
                    <font size=10>%s</font>
                ''' % (_('Done at'), _('The'), _('Signature')),
                p_signature)
    content.append(P)
开发者ID:fthuin,项目名称:osis,代码行数:21,代码来源:pdf_utils.py

示例9: getExamples

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
def getExamples():
    """Returns all the example flowable objects"""
    styleSheet = getSampleStyleSheet()

    story = []

    #make a style with indents and spacing
    sty = ParagraphStyle('obvious', None)
    sty.leftIndent = 18
    sty.rightIndent = 18
    sty.firstLineIndent = 18
    sty.spaceBefore = 6
    sty.spaceAfter = 6
    story.append(Paragraph("""Now for some demo stuff - we need some on this page,
        even before we explain the concepts fully""", styleSheet['BodyText']))
    p = Paragraph("""
        Platypus is all about fitting objects into frames on the page.  You
        are looking at a fairly simple Platypus paragraph in Debug mode.
        It has some gridlines drawn around it to show the left and right indents,
        and the space before and after, all of which are attributes set in
        the style sheet.  To be specific, this paragraph has left and
        right indents of 18 points, a first line indent of 36 points,
        and 6 points of space before and after itself.  A paragraph
        object fills the width of the enclosing frame, as you would expect.""", sty)

    p.debug = 1   #show me the borders
    story.append(p)

    story.append(Paragraph("""Same but with justification 1.5 extra leading and green text.""", styleSheet['BodyText']))
    p = Paragraph("""
        <para align=justify leading=+1.5 fg=green><font color=red>Platypus</font> is all about fitting objects into frames on the page.  You
        are looking at a fairly simple Platypus paragraph in Debug mode.
        It has some gridlines drawn around it to show the left and right indents,
        and the space before and after, all of which are attributes set in
        the style sheet.  To be specific, this paragraph has left and
        right indents of 18 points, a first line indent of 36 points,
        and 6 points of space before and after itself.  A paragraph
        object fills the width of the enclosing frame, as you would expect.</para>""", sty)

    p.debug = 1   #show me the borders
    story.append(p)

    story.append(platypus.XBox(4*inch, 0.75*inch,
            'This is a box with a fixed size'))

    story.append(Paragraph("""
        All of this is being drawn within a text frame which was defined
        on the page.  This frame is in 'debug' mode so you can see the border,
        and also see the margins which it reserves.  A frame does not have
        to have margins, but they have been set to 6 points each to create
        a little space around the contents.
        """, styleSheet['BodyText']))

    story.append(FrameBreak())

    #######################################################################
    #     Examples Page 2
    #######################################################################

    story.append(Paragraph("""
        Here's the base class for Flowable...
        """, styleSheet['Italic']))

    code = '''class Flowable:
        """Abstract base class for things to be drawn.  Key concepts:
    1. It knows its size
    2. It draws in its own coordinate system (this requires the
        base API to provide a translate() function.
        """
    def __init__(self):
        self.width = 0
        self.height = 0
        self.wrapped = 0

    def drawOn(self, canvas, x, y):
        "Tell it to draw itself on the canvas.  Do not override"
        self.canv = canvas
        self.canv.saveState()
        self.canv.translate(x, y)

        self.draw()   #this is the bit you overload

        self.canv.restoreState()
        del self.canv

    def wrap(self, availWidth, availHeight):
        """This will be called by the enclosing frame before objects
        are asked their size, drawn or whatever.  It returns the
        size actually used."""
        return (self.width, self.height)
    '''

    story.append(Preformatted(code, styleSheet['Code'], dedent=4))
    story.append(FrameBreak())
    #######################################################################
    #     Examples Page 3
    #######################################################################

    story.append(Paragraph(
                "Here are some examples of the remaining objects above.",
#.........这里部分代码省略.........
开发者ID:roytest001,项目名称:PythonCode,代码行数:103,代码来源:test_platypus_general.py

示例10: testRTLBullets

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
        def testRTLBullets(self):
            try:
                import mwlib.ext
            except ImportError:
                pass

            font_name = getAFont()
            doc = SimpleDocTemplate(outputfile('test_rtl_bullets.pdf'),showBoundary=True)
            p_style = ParagraphStyle('default')
            p_style.leftIndent = 0
            p_style.rightIndent = 0

            list_styles=[ParagraphStyle('list%d' % n) for n in range(3)]
            all_styles = list_styles[:]
            all_styles.append(p_style)

            direction='rtl'

            for s in all_styles:
                s.fontSize = 15
                s.leading = s.fontSize*1.2
                s.fontName = font_name
                if direction=='rtl':
                    s.wordWrap = 'RTL'
                    s.alignment = TA_RIGHT
                else:
                    s.alignment = TA_JUSTIFY

            indent_amount = 20

            for list_lvl, list_style in enumerate(list_styles):
                list_lvl += 1
                list_style.bulletIndent = indent_amount*(list_lvl-1)

                if direction=='rtl':
                    list_style.rightIndent = indent_amount*list_lvl
                else:
                    list_style.leftIndent = indent_amount*list_lvl

            elements =[]

            TEXTS=[
                    b'\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x91\xd7\x99\xd7\x98\xd7\x97\xd7\x95\xd7\x9f, \xd7\x94\xd7\x95\xd7\x90 \xd7\x94\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x90\xd7\x97\xd7\xa8\xd7\x90\xd7\x99 \xd7\xa2\xd7\x9c \xd7\x9e\xd7\xa9\xd7\xa8\xd7\x93 \xd7\x96\xd7\x94. \xd7\xaa\xd7\xa4\xd7\xa7\xd7\x99\xd7\x93 \xd7\x96\xd7\x94 \xd7\xa0\xd7\x97\xd7\xa9\xd7\x91 \xd7\x9c\xd7\x90\xd7\x97\xd7\x93 \xd7\x94\xd7\xaa\xd7\xa4\xd7\xa7\xd7\x99\xd7\x93\xd7\x99\xd7\x9d \xd7\x94\xd7\x91\xd7\x9b\xd7\x99\xd7\xa8\xd7\x99\xd7\x9d \xd7\x91\xd7\x9e\xd7\x9e\xd7\xa9\xd7\x9c\xd7\x94. \xd7\x9c\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x91\xd7\x99\xd7\x98\xd7\x97\xd7\x95\xd7\x9f \xd7\x9e\xd7\xaa\xd7\x9e\xd7\xa0\xd7\x94 \xd7\x9c\xd7\xa8\xd7\x95\xd7\x91 \xd7\x92\xd7\x9d \xd7\xa1\xd7\x92\xd7\x9f \xd7\xa9\xd7\xa8.',
                    b'\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x91\xd7\x99\xd7\x98\xd7\x97\xd7\x95\xd7\x9f, <b>\xd7\x94\xd7\x95\xd7\x90 \xd7\x94\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x90\xd7\x97\xd7\xa8\xd7\x90\xd7\x99 \xd7\xa2\xd7\x9c \xd7\x9e\xd7\xa9\xd7\xa8\xd7\x93 \xd7\x96\xd7\x94.</b> \xd7\xaa\xd7\xa4\xd7\xa7\xd7\x99\xd7\x93 \xd7\x96\xd7\x94 <i>\xd7\xa0\xd7\x97\xd7\xa9\xd7\x91 \xd7\x9c\xd7\x90\xd7\x97\xd7\x93</i> \xd7\x94\xd7\xaa\xd7\xa4\xd7\xa7\xd7\x99\xd7\x93\xd7\x99\xd7\x9d <b><i>\xd7\x94\xd7\x91\xd7\x9b\xd7\x99\xd7\xa8\xd7\x99\xd7\x9d \xd7\x91\xd7\x9e\xd7\x9e\xd7\xa9\xd7\x9c\xd7\x94</i></b>. \xd7\x9c\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x91\xd7\x99\xd7\x98\xd7\x97\xd7\x95\xd7\x9f \xd7\x9e\xd7\xaa\xd7\x9e\xd7\xa0\xd7\x94 \xd7\x9c\xd7\xa8\xd7\x95\xd7\x91 \xd7\x92\xd7\x9d \xd7\xa1\xd7\x92\xd7\x9f \xd7\xa9\xd7\xa8.',
                    u'<bullet>\u2022</bullet>\u05e9\u05e8 \u05d4\u05d1\u05d9\u05d8\u05d7\u05d5\u05df, <b>\u05d4\u05d5\u05d0 \u05d4\u05e9\u05e8 \u05d4\u05d0\u05d7\u05e8\u05d0\u05d9 \u05e2\u05dc \u05de\u05e9\u05e8\u05d3 \u05d6\u05d4.</b> \u05ea\u05e4\u05e7\u05d9\u05d3 \u05d6\u05d4 <i>\u05e0\u05d7\u05e9\u05d1 \u05dc\u05d0\u05d7\u05d3</i> \u05d4\u05ea\u05e4\u05e7\u05d9\u05d3\u05d9\u05dd <b><i>\u05d4\u05d1\u05db\u05d9\u05e8\u05d9\u05dd \u05d1\u05de\u05de\u05e9\u05dc\u05d4</i></b>. \u05dc\u05e9\u05e8\u05d4\u05d1\u05d9\u05d8\u05d7\u05d5\u05df \u05de\u05ea\u05de\u05e0\u05d4 \u05dc\u05e8\u05d5\u05d1 \u05d2\u05dd \u05e1\u05d2\u05df \u05e9\u05e8.',
                    ]

            # simple text in a paragraph
            # working with patch from Hosam Aly
            p = Paragraph(TEXTS[0], p_style)
            elements.append(p)

            elements.append(Spacer(0, 40))

            # uses intra paragraph markup -> style text
            p = Paragraph(TEXTS[1], p_style)
            elements.append(p)
            elements.append(Spacer(0, 40))

            # list item (just a paragraph with a leading <bullet> element
            for list_style in list_styles:
                p = Paragraph(TEXTS[2], list_style)
                elements.append(p)

            doc.build(elements)
开发者ID:Distrotech,项目名称:reportlab,代码行数:67,代码来源:test_paragraphs.py

示例11: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
    def toParagraphStyle(self, first, full=False):
        style = ParagraphStyle('default%d' % self.UID(), keepWithNext=first.keepWithNext)
        style.fontName = first.fontName
        style.fontSize = first.fontSize
        style.leading = max(first.leading, 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
        
        # 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
        
        # This is the old code replaced by the above, kept for reference
        #style.borderWidth = 0
        #if getBorderStyle(first.borderTopStyle):
        #    style.borderWidth = max(first.borderLeftWidth, first.borderRightWidth, first.borderTopWidth, first.borderBottomWidth)
        #    style.borderPadding = first.borderPadding # + first.borderWidth
        #    style.borderColor = first.borderTopColor
        #    # If no border color is given, the text color is used (XXX Tables!)
        #    if (style.borderColor is None) and style.borderWidth:
        #        style.borderColor = first.textColor      



        if full:
            style.fontName = tt2ps(first.fontName, first.bold, first.italic)
        return style       
开发者ID:huongchinguyen0202,项目名称:helicopter,代码行数:69,代码来源:pisa_context.py

示例12: imprimir

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
  def imprimir(self, venta):

    subirmas  = 5 * mm

    buffer = self.buffer
    doc = SimpleDocTemplate(buffer, pagesize = self.pagesize, topMargin = 12.5 * cm - subirmas, leftMargin = 1 * cm, rightMargin = 1 * cm, bottomMargin = 3.5 * cm , showBoundary = 0)

    pdfmetrics.registerFont(TTFont('A1979', 'A1979.ttf'))

    styles = getSampleStyleSheet()
    style = ParagraphStyle('A1979')
    style.fontName = 'A1979'
    style.fontSize = 7

    styler = ParagraphStyle('A1979R')
    styler.fontName = 'A1979'
    styler.fontSize = 7
    styler.alignment = TA_RIGHT

    stylep = ParagraphStyle('A1979P')
    stylep.fontName = 'A1979'
    stylep.fontSize = 7
    stylep.leftIndent = 5

    elements = []

    tabla = []

    for detalle in venta.ventadetalle_set.all():
      fila = []
      fila.append(Paragraph(str(detalle.cantidad), style))
      fila.append(Paragraph(detalle.lote.producto.unidad_medida.upper(), style))

      comercial = detalle.lote.producto.comercial.upper()
      if comercial == '':
        the_prod = '%s - %s' % (detalle.lote.producto.producto.upper(), unidecode(detalle.lote.producto.marca.upper()))
      else:
        the_prod = '%s / %s - %s' % (detalle.lote.producto.producto.upper(), comercial, unidecode(detalle.lote.producto.marca.upper()))

      fila.append(Paragraph(the_prod, style))

      tabla.append(fila)

      if detalle.lote.numero or detalle.lote.vencimiento:
        string = ''
        fila = ['']
        fila.append(Spacer(0, 1 *mm))
        if detalle.lote.numero:
          string += 'LOTE: %s          ' % detalle.lote.numero
        if detalle.lote.vencimiento:
          string += ' / VCTO: %s' % detalle.lote.vencimiento.strftime('%d/%m/%Y')

        fila.append(Paragraph(string, stylep))
        tabla.append(fila)


    detalles_tabla = Table(tabla, colWidths = [10 * mm, 13 * mm, None], style = tabla_requerimiento_estilo_ref(),
        repeatRows = 1)

    elements.append(detalles_tabla)

    doc.build(elements, onFirstPage = partial(self._header_footer, venta = venta),
      onLaterPages = partial(self._header_footer, venta = venta))

    pdf = buffer.getvalue()
    buffer.close()
    return pdf
开发者ID:soncco,项目名称:hampi,代码行数:69,代码来源:printable.py

示例13: createPDF

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]

#.........这里部分代码省略.........
        styles['Heading3'].textColor = header_rgb
                
        styles['Heading4'].allowWidows = 0
        styles['Heading4'].fontName = 'Helvetica-Bold'
        styles['Heading4'].fontSize = 10
        styles['Heading4'].leading = 12
        styles['Heading4'].spaceAfter = 6
        styles['Heading4'].textColor = header_rgb
        
        th_cell = ParagraphStyle('TableHeading')
        th_cell.spaceBefore = 3
        th_cell.spaceAfter = 6
        th_cell.fontSize = 10
        th_cell.fontName = 'Times-Bold'

        td_cell = ParagraphStyle('TableData')
        td_cell.spaceBefore = 3
        td_cell.spaceAfter = 6
        td_cell.fontSize = 10
        td_cell.fontName = 'Times-Roman'

        td_cell_right = ParagraphStyle('TableDataRight')
        td_cell_right.spaceBefore = 3
        td_cell_right.spaceAfter = 6
        td_cell_right.fontSize = 10
        td_cell_right.fontName = 'Times-Roman'
        td_cell_right.alignment = TA_RIGHT

        bullet_list = ParagraphStyle('BulletList')
        bullet_list.spaceBefore = 4
        bullet_list.spaceAfter = 4
        bullet_list.fontName = 'Times-Roman'
        bullet_list.bulletIndent = 5
        bullet_list.leftIndent = 17
        bullet_list.bulletFontSize = 12

        blockquote = ParagraphStyle('Blockquote')
        blockquote.leftIndent = 12
        blockquote.rightIndent = 8
        blockquote.spaceAfter = 6
        blockquote.fontName = 'Times-Roman'

        discreet = ParagraphStyle('Discreet')
        discreet.fontSize = 9
        discreet.textColor = HexColor('#717171')
        discreet.spaceAfter = 12
        discreet.spaceBefore = 1

        callout = ParagraphStyle('Callout')
        callout.fontSize = 10
        callout.textColor = header_rgb
        callout.spaceAfter = 20
        callout.spaceBefore = 22
        callout.backColor = callout_background_rgb
        callout.borderColor = header_rgb
        callout.borderWidth = 1
        callout.borderPadding = (8, 12, 10, 12)
        callout.rightIndent = 15
        callout.leftIndent = 15

        statement = ParagraphStyle('Statement')
        statement.fontSize = 8
        statement.fontName = 'Times-Roman'
        statement.spaceAfter = 5
        statement.leading = 10
开发者ID:tsimkins,项目名称:agsci.ExtensionExtender,代码行数:69,代码来源:pdf.py

示例14: generate_pdf_cotizacion

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import leftIndent [as 别名]
def generate_pdf_cotizacion(request,id_cotizacion):
	
	# Declaracion de variables
	iva = 12
	path = './sistema_sfc/static/images/'
	total = 0
	elements = []
	total_productos = []
	objeto = {"cantidad":0, "descripcion":0, "talla":0, "precio_unitario":0, "precio_total":0}

	# Declaracion variables del apartado 'Observaciones' de la cotizacion
	tiempo_entrega = 15
	periodo_validez = 2
	condicion_pago_final = 50
	condicion_pago_inicial = 50
	
	# convertir a formato string para ser dibujado en la cotizacion
	tiempo_entrega_str = str(tiempo_entrega)
	periodo_validez_str = str(periodo_validez)
	condicion_pago_final_str = str(condicion_pago_final)
	condicion_pago_inicial_str = str(condicion_pago_inicial)	

	# Informacion de la cotizacion con id = id_cotizacion
	cotizacion = Cotizacion.objects.get(id = id_cotizacion)
	
	# Productos pertenecientes a la cotizacion con id = id_cotizacion
	productos_cotizacion = Producto_has_cotizacion.objects.filter(cotizacion_id_cotizacion_id = cotizacion.id).extra(select={'cotizacion_id_cotizacion_id':cotizacion.id})
	
	# Todos los productos
	productos = Producto.objects.order_by('id')
	
	# Cliente perteneciente a la cotizacion con id = id_cotizacion
	cliente = Cliente.objects.get(id=cotizacion.cliente_identificacion_id)

	# Observaciones pertenecientes a la cotizacion con id = id_cotizacion
	observaciones_cotizacion = Observacion.objects.filter(cotizacion_id = cotizacion.id).extra(select={'cotizacion_id':cotizacion.id})
	
	
	# Ciclo para obtener todos los productos con su cantidad, talla y precio para ser dibujado en
	# la tabla, el resultado se almacena en el array 'total_productos' de objetos con el formato:
	# {"cantidad":0, "descripcion":0, "talla":0, "precio_unitario":0, "precio_total":0}
	# y el subtotal (suma de todo los precios) en la variable total.

	for item in productos_cotizacion:
		for producto in productos:
			if producto.id == item.producto_id_producto_id:
				objeto['descripcion'] = producto.descripcion
				break
		objeto['cantidad'] = item.cantidad
		objeto['talla'] = item.talla
		objeto['precio_unitario'] = item.precio
		objeto['precio_total'] = (item.precio * item.cantidad)*(1+(item.ganancia / 100))
		total_productos.append(objeto)
		total += (item.precio * item.cantidad)*(1+(item.ganancia / 100))
		objeto = {"cantidad":0, "descripcion":0, "talla":0, "precio_unitario":0, "precio_total":0}

	# Calculo de subtotal, iva, total
	sub_total = total
	iva_total = (total * iva) / 100
	total = iva_total + sub_total

	response = HttpResponse(content_type='application/pdf')
	response['Content-Disposition'] = 'attachment; filename="COTIZACION '+id_cotizacion+' '+cliente.nombre+'.pdf"'


	# Creacion del pdf 
	# Creacion de la hoja de pdf
	styles = getSampleStyleSheet()
	doc = SimpleDocTemplate(response, pagesize=A4, rightMargin=30,leftMargin=30, topMargin=30,bottomMargin=18)
	
	# Logo de la Empresa
	name_logo = path + "logo.png"
	imagen = Image(name_logo, width=240, height=93)
	imagen.hAlign = 'LEFT'
	elements.append(imagen)
	
	# annadir espacio derecho en la hoja pdf
	elements.append(Spacer(0, -90))

	# icono de telefono
	name_icon_telefono = path + "icon-phone.jpg"
	com_telefono = 'canvas.drawImage("'+name_icon_telefono+'",320,-20,12,12)'
	elements.append(flowables.Macro(com_telefono))
	
	# annadir espacio derecho en la hoja pdf
	elements.append(Spacer(0, 8))
	
	# Agregar estilo al texto del telefono
	ps = ParagraphStyle("indented")
	ps.leftIndent = 340
	texto_telefono = Paragraph('0414-863.67.29 / 0424-919.89.92', ps)
	elements.append(texto_telefono)

	# icono de twitter
	name_icon_twitter = path + "icon-twitter.jpg"
	com_twitter = 'canvas.drawImage("'+name_icon_twitter+'",320,-20,12,12)'
	elements.append(flowables.Macro(com_twitter))
	
	# annadir espacio derecho en la hoja pdf
	elements.append(Spacer(0, 8))
#.........这里部分代码省略.........
开发者ID:guiulianahp,项目名称:scf,代码行数:103,代码来源:views.py


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