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


Python ParagraphStyle.textColor方法代码示例

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


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

示例1: toParagraphStyle

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

示例2: addStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
 def addStyle(self, data):
     def addFont(fontfile):
         if not fontfile:
             return None
         elif fontfile.endswith(".ttf") or fontfile.endswith(".otf"):
             fontname = os.path.splitext(fontfile)[0]
             pdfmetrics.registerFont(TTFont(fontname, fontfile))
             print "Registered", fontfile
             return fontname
         else:
             return fontfile
     name = data.get('name', "")
     s = ParagraphStyle(name)
     normal = addFont(data.get('font', "Helvetica"))
     bold = addFont(data.get('bold', None))
     italic = addFont(data.get('italic', None))
     bolditalic = addFont(data.get('bolditalic', None))
     pdfmetrics.registerFontFamily(normal, normal=normal, bold=bold or normal, italic=italic or normal, boldItalic=bolditalic or normal)
     s.fontName = normal
     s.fontSize = data.get('size', 10)
     s.alignment = dict(center=TA_CENTER, left=TA_LEFT, right=TA_RIGHT)[data.get('align', 'left')]
     s.leading = data.get('leading', s.leading)
     s.valign = data.get('valign', "top")
     s.textColor = data.get('color', "#ff000000")
     self.styles[name] = s
开发者ID:mcccclean,项目名称:card-renderer,代码行数:27,代码来源:pdfcanvas.py

示例3: toParagraphStyle

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

示例4: parag_style

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
def parag_style():
    from  reportlab.lib.styles import ParagraphStyle
    from reportlab.lib.enums import TA_LEFT
    style = ParagraphStyle('test')
    style.textColor = 'black'
    style.borderColor = 'black'
    style.borderWidth = 0
    style.alignment = TA_LEFT
    style.fontSize = 9
    return style
开发者ID:efornal,项目名称:mollys,代码行数:12,代码来源:views.py

示例5: runBuild

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
 def runBuild(self, str):
     p = ParagraphStyle('test')
     p.textColor = self.FONTCOLOR
     p.borderWidth = 0
     p.fontSize = self.FONTSIZE
     p.fontName = self.FONTNAME
     p.leading = 12 * self.FONTSIZE / 10
     for line in str:
         para = Paragraph("%s" % line, p)
         self.story.append(para)
     self.doc.build(self.story, onFirstPage=self.pageCanvas,
         onLaterPages=self.pageCanvas)
开发者ID:jonaubf,项目名称:PassageScrapper,代码行数:14,代码来源:passage_scrapper.py

示例6: insert_line

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

示例7: build_head2

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
def build_head2(texto, ancho_linea = PAGE_WIDTH - 5.5*cm, offset_linea = 0.0):
    """
    Devuelve el texto con el estilo de encabezado de 2º. nivel y el subrayado.
    """
    estilo_head2 = ParagraphStyle("Header2", 
                                  parent = estilos["Normal"])
    estilo_head2.fontSize = 14
    estilo_head2.fontName = "Times-Italic"
    estilo_head2.textColor = colors.gray
    texto = Paragraph(escribe(texto), estilo_head2)
    linea = LineaHorizontal(ancho_linea, offset = offset_linea, 
                            color = colors.green)
    return KeepTogether([texto, Spacer(1, 0.1*cm), linea, Spacer(1, 0.15*cm)])
开发者ID:pacoqueen,项目名称:ginn,代码行数:15,代码来源:informe_certificado_calidad.py

示例8: drawMetadata

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
    def drawMetadata(self):
        data = [('Artist', self.artist), ('Made', self.place), ('Date', self.date)]
        data = self.artist + ", " + self.date + ", " + self.place
#        self.canvas.setFont('TheSans', 12)
#        self.canvas.drawString(PAGE_HEIGHT*0.635, PAGE_WIDTH*0.86, data)

        parastyle = ParagraphStyle('pad')
        parastyle.textColor = 'black'
        parastyle.fontSize = 10
        parastyle.leading = 20
        parastyle.font = 'TheSans-Bold'
        paragraph = Paragraph(data, parastyle)
        paragraph.wrapOn(self.canvas, PAGE_HEIGHT*0.25, PAGE_WIDTH*0.1)
        paragraph.drawOn(self.canvas, PAGE_HEIGHT*0.635, PAGE_WIDTH*0.84)
开发者ID:vanda,项目名称:vamcolouring,代码行数:16,代码来源:colouring-in.py

示例9: addStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
	def addStyle(self, data):
		name = data.get('name', "")
		s = ParagraphStyle(name)
		fontfile = data.get('font', "Helvetica")
		if fontfile.endswith(".ttf") or fontfile.endswith(".otf"):
			fontname = os.path.splitext(fontfile)[0]
			pdfmetrics.registerFont(TTFont(fontname, fontfile))
			s.fontName = fontname
		else:
			s.fontName = fontfile
		s.fontSize = data.get('size', 10)
		s.alignment = dict(center=TA_CENTER, left=TA_LEFT, right=TA_RIGHT)[data.get('align', 'left')]
		s.leading = data.get('leading', s.leading)
		s.valign = data.get('valign', "top")
		s.textColor = data.get('color', "#ff000000")
		self.styles[name] = s
开发者ID:isaacwilliams,项目名称:card-renderer,代码行数:18,代码来源:pdfcanvas.py

示例10: legend_building

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
def legend_building(learning_unit_year, is_fac, content, styles):
    content.append(BIG_INTER_LINE)
    content.append(BIG_INTER_LINE)
    p = ParagraphStyle('legend')
    p.textColor = 'grey'
    p.borderColor = 'grey'
    p.borderWidth = 1
    p.alignment = TA_CENTER
    p.fontSize =8
    p.borderPadding = 5
    legend_text = "%s : %s" % (_('Other score legend'), ExamEnrollment.justification_label_authorized(is_fac))
    if not learning_unit_year.decimal_scores:
        legend_text += "<br/><font color=red>%s</font>" % _('UnAuthorized decimal for this activity')

    content.append(Paragraph('''
                            <para>
                                %s
                            </para>
                            ''' % legend_text, p))
开发者ID:fthuin,项目名称:osis,代码行数:21,代码来源:pdf_utils.py

示例11: cover

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
 def cover(self):
     """ Display a cover.
     """
     # Define a style for the cover
     cover = ParagraphStyle("Cover")
     cover.textColor = "black"
     cover.borderColor = "black"
     cover.borderPadding = 80
     cover.borderWidth = 1
     cover.alignment = TA_CENTER
     cover.fontSize = 30
     cover.borderRadius = 20
     cover.backColor = "gray"
     cover.leading = 40
     pagesize = self.templates["OneCol"]["pagesize"]
     self.story.append(Cover(pagesize[0], pagesize[1] / 3, self.author,
                             self.client, self.poweredby, self.project,
                             self.timepoint, self.subject, self.date))
     self.story.append(Spacer(0, pagesize[1] / 2))
     self.story.append(Paragraph(self.title, cover))
开发者ID:neurospin,项目名称:pyconnectomist,代码行数:22,代码来源:pdftools.py

示例12: drawPAD

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
    def drawPAD(self, pad=None, historical=None):
# TODO - Choose PAD or other description. Limit length. Longer if image small
        if self.pad:
            pad_text = self.pad
        else:
            pad_text = ''
        if self.historical_context_note:
            hist_text = self.historical_context_note
        else:
            hist_text = None
        if self.descriptive_line:
            desc_text = self.descriptive_line
        else:
            desc_text = None

        if len(pad_text) > 1000:
            pad_text_short = pad_text[0:1000]
            i = 0
            while i < 100:
                if pad_text[1000+i] == "." or pad_text[1000+i] == "?":
                    break
                i += 1
            pad_text_short = pad_text_short + pad_text[1000:1000+i+1] + "[...]"
        else:
            pad_text_short = pad_text

        parastyle = ParagraphStyle('pad')
        parastyle.textColor = 'black'
        parastyle.fontSize = 12
        parastyle.leading = 20
        parastyle.fontName = "TheSans"
        paragraph = Paragraph(pad_text_short, parastyle)
#        self.canvas.saveState()
#        self.canvas.setFont('Times-Bold', 12)
#        self.canvas.drawString(PAGE_WIDTH*0.1, PAGE_HEIGHT*0.1, pad)
#        self.canvas.restoreState()
#        paragraph.WrapOn(self.canvas, 
        print("Public Access Text: %s", pad_text)
        paragraph.wrapOn(self.canvas, PAGE_HEIGHT*0.35, PAGE_WIDTH*0.78)
        paragraph.drawOn(self.canvas, PAGE_HEIGHT*0.635, PAGE_WIDTH*0.12)
开发者ID:vanda,项目名称:vamcolouring,代码行数:42,代码来源:colouring-in.py

示例13: build_pdf

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
def build_pdf(image_file):
    filename = "%s.pdf" % _('scores_sheet')
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="%s"' % filename

    buffer = BytesIO()
    doc = SimpleDocTemplate(buffer,
                            pagesize=PAGE_SIZE,
                            rightMargin=MARGIN_SIZE,
                            leftMargin=MARGIN_SIZE,
                            topMargin=TOP_MARGIN,
                            bottomMargin=BOTTOM_MARGIN)
    image1 = get_image2(image_file)

    styles = getSampleStyleSheet()
    styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
    content = [image1]
    p = ParagraphStyle('legend')
    p.textColor = 'grey'
    p.borderColor = 'grey'
    p.borderWidth = 1
    p.alignment = TA_CENTER
    p.fontSize = 8
    p.borderPadding = 5

    legend_text = 'justification_legend'
    legend_text += "<br/><font color=red>%s</font>" % 'fffff'

    content.append(Paragraph('''
                            <para>
                                %s
                            </para>
                            ''' % legend_text, p))
    doc.build(content)
    pdf = buffer.getvalue()
    buffer.close()
    response.write(pdf)
    return response
开发者ID:verpoorten,项目名称:immobilier,代码行数:40,代码来源:image.py

示例14: _draw_item

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
    def _draw_item(self, canvas, item, tpl_data, content, margin_x, margin_y):
        style = ParagraphStyle({})
        style.alignment = ALIGNMENTS[item['text_align']]
        style.textColor = COLORS[item['color']]
        style.fontSize = _extract_font_size(item['font_size'])
        style.leading = style.fontSize

        if item['bold'] and item['italic']:
            style.fontName = FONT_STYLES[item['font_family']][3]
        elif item['italic']:
            style.fontName = FONT_STYLES[item['font_family']][2]
        elif item['bold']:
            style.fontName = FONT_STYLES[item['font_family']][1]
        else:
            style.fontName = FONT_STYLES[item['font_family']][0]

        item_x = float(item['x']) / PIXELS_CM * cm
        item_y = float(item['y']) / PIXELS_CM * cm
        item_width = item['width'] / PIXELS_CM * cm
        item_height = (item['height'] / PIXELS_CM * cm) if item.get('height') is not None else None

        if isinstance(content, Image.Image):
            canvas.drawImage(ImageReader(content), margin_x + item_x, self.height - margin_y - item_height - item_y,
                             item_width, item_height)
        else:
            content = strip_tags(content)
            for line in content.splitlines():
                p = Paragraph(line, style)
                available_height = (tpl_data.height_cm - (item_y / PIXELS_CM)) * cm

                w, h = p.wrap(item_width, available_height)
                if w > item_width or h > available_height:
                    # TODO: add warning
                    pass

                p.drawOn(canvas, margin_x + item_x, self.height - margin_y - item_y - h)
                item_y += h
开发者ID:indico,项目名称:indico,代码行数:39,代码来源:pdf.py

示例15: generate_pdf

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import textColor [as 别名]
def generate_pdf(opts, notes):
    outfile = os.path.join(opts.outdir, 'out.pdf')

    tallest_note = -1
    for n in notes:
        lines = simpleSplit(n, opts.font, opts.font_size, opts.note_width)
        tallest_note = max(tallest_note, len(lines))

    note_height = ((tallest_note + 1) * opts.leading) + (opts.notepadding * 2)

    s = ParagraphStyle('note')
    s.fontName = opts.font
    s.textColor = 'black'
    s.alignment = TA_LEFT
    s.fontSize = opts.font_size
    s.leading = opts.leading

    img_w, img_h = opts.pagesize
    pagesize = (img_w, img_h + note_height)

    c = canvas.Canvas(outfile, pagesize=pagesize)
    c.setStrokeColorRGB(0, 0, 0)

    for slide, note in slides_and_notes(opts, notes):
        c.setFillColor(HexColor('#ffffff'))
        c.rect(0, 0, img_w, img_h + note_height, fill=1)

        c.drawImage(slide, 0, note_height, img_w, img_h, preserveAspectRatio=True)
        c.line(0, note_height, img_w, note_height)

        if note:
            p = Paragraph(note.replace('\n', '<br/>'), s)
            p.wrapOn(c, opts.note_width, note_height)
            p.breakLines(opts.note_width)
            p.drawOn(c, opts.notepadding, note_height - opts.notepadding)
        c.showPage()
    c.save()
开发者ID:mcfunley,项目名称:keynote-fix,代码行数:39,代码来源:export.py


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