本文整理汇总了Python中reportlab.lib.styles.ParagraphStyle.borderWidth方法的典型用法代码示例。如果您正苦于以下问题:Python ParagraphStyle.borderWidth方法的具体用法?Python ParagraphStyle.borderWidth怎么用?Python ParagraphStyle.borderWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.lib.styles.ParagraphStyle
的用法示例。
在下文中一共展示了ParagraphStyle.borderWidth方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: toParagraphStyle
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [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
示例2: addPara
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [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()
示例3: parag_style
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [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
示例4: runBuild
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [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)
示例5: legend_building
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [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))
示例6: cover
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [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))
示例7: build_pdf
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [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
示例8: _test0
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [as 别名]
def _test0(self):
"This makes one long multi-page paragraph."
# Build story.
story = []
a = story.append
styleSheet = getSampleStyleSheet()
h1 = styleSheet['Heading1']
h1.pageBreakBefore = 1
h1.keepWithNext = 1
h2 = styleSheet['Heading2']
h2.frameBreakBefore = 1
h2.keepWithNext = 1
h3 = styleSheet['Heading3']
h3.backColor = colors.cyan
h3.keepWithNext = 1
bt = styleSheet['BodyText']
btj = ParagraphStyle('bodyText1j',parent=bt,alignment=TA_JUSTIFY)
btr = ParagraphStyle('bodyText1r',parent=bt,alignment=TA_RIGHT)
btc = ParagraphStyle('bodyText1c',parent=bt,alignment=TA_CENTER)
a(Paragraph("""
<a name='top'/>Subsequent pages test pageBreakBefore, frameBreakBefore and
keepTogether attributes. Generated at %s. The number in brackets
at the end of each paragraph is its position in the story. (%d)""" % (
time.ctime(time.time()), len(story)), bt))
for i in range(10):
a(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1))
for j in range(3):
a(Paragraph('Heading1 paragraphs should always'
'have a page break before. Heading 2 on the other hand'
'should always have a FRAME break before (%d)' % len(story), bt))
a(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2))
a(Paragraph('Heading1 paragraphs should always'
'have a page break before. Heading 2 on the other hand'
'should always have a FRAME break before (%d)' % len(story), bt))
for j in range(3):
a(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt))
a(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3))
a(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt))
for align,bts in [('left',bt),('JUSTIFIED',btj),('RIGHT',btr),('CENTER',btc)]:
a(Paragraph('Now we do <br/> tests(align=%s)' % align, h1))
a(Paragraph('First off no br tags',h3))
a(Paragraph(_text1,bts))
a(Paragraph("<br/> after 'the' in line 4",h3))
a(Paragraph(_text1.replace('forms of the','forms of the<br/>',1),bts))
a(Paragraph("2*<br/> after 'the' in line 4",h3))
a(Paragraph(_text1.replace('forms of the','forms of the<br/><br/>',1),bts))
a(Paragraph("<br/> after 'I suggested ' in line 5",h3))
a(Paragraph(_text1.replace('I suggested ','I suggested<br/>',1),bts))
a(Paragraph("2*<br/> after 'I suggested ' in line 5",h3))
a(Paragraph(_text1.replace('I suggested ','I suggested<br/><br/>',1),bts))
a(Paragraph("<br/> at the end of the paragraph!",h3))
a(Paragraph("""text one<br/>text two<br/>""",bts))
a(Paragraph("Border with <br/> at the end of the paragraph!",h3))
bt1 = ParagraphStyle('bodyText1',bts)
bt1.borderWidth = 0.5
bt1.borderColor = colors.toColor('red')
bt1.backColor = colors.pink
bt1.borderRadius = 2
bt1.borderPadding = 3
a(Paragraph("""text one<br/>text two<br/>""",bt1))
a(Paragraph("Border no <br/> at the end of the paragraph!",h3))
bt1 = ParagraphStyle('bodyText1',bts)
bt1.borderWidth = 0.5
bt1.borderColor = colors.toColor('red')
bt1.backColor = colors.pink
bt1.borderRadius = 2
bt1.borderPadding = 3
a(Paragraph("""text one<br/>text two""",bt1))
a(Paragraph("Different border style!",h3))
bt2 = ParagraphStyle('bodyText1',bt1)
bt2.borderWidth = 1.5
bt2.borderColor = colors.toColor('blue')
bt2.backColor = colors.gray
bt2.borderRadius = 3
bt2.borderPadding = 3
a(Paragraph("""text one<br/>text two<br/>""",bt2))
for i in 0, 1, 2:
P = Paragraph("""This is a paragraph with <font color='blue'><a href='#top'>with an incredibly
long and boring link in side of it that
contains lots and lots of stupidly boring and worthless information.
So that we can split the link and see if we get problems like Dinu's.
I hope we don't, but you never do Know.</a></font>""",bt)
a(P)
doc = MyDocTemplate(outputfile('test_platypus_breaking.pdf'))
doc.multiBuild(story)
示例9: _test0
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [as 别名]
def _test0(self):
"This makes one long multi-page paragraph."
# Build story.
story = []
a = story.append
styleSheet = getSampleStyleSheet()
h1 = styleSheet["Heading1"]
h1.pageBreakBefore = 1
h1.keepWithNext = 1
h2 = styleSheet["Heading2"]
h2.frameBreakBefore = 1
h2.keepWithNext = 1
h3 = styleSheet["Heading3"]
h3.backColor = colors.cyan
h3.keepWithNext = 1
bt = styleSheet["BodyText"]
a(
Paragraph(
"""
Subsequent pages test pageBreakBefore, frameBreakBefore and
keepTogether attributes. Generated at %s. The number in brackets
at the end of each paragraph is its position in the story. (%d)"""
% (time.ctime(time.time()), len(story)),
bt,
)
)
for i in xrange(10):
a(Paragraph("Heading 1 always starts a new page (%d)" % len(story), h1))
for j in xrange(3):
a(
Paragraph(
"Heading1 paragraphs should always"
"have a page break before. Heading 2 on the other hand"
"should always have a FRAME break before (%d)" % len(story),
bt,
)
)
a(Paragraph("Heading 2 always starts a new frame (%d)" % len(story), h2))
a(
Paragraph(
"Heading1 paragraphs should always"
"have a page break before. Heading 2 on the other hand"
"should always have a FRAME break before (%d)" % len(story),
bt,
)
)
for j in xrange(3):
a(Paragraph(randomText(theme=PYTHON, sentences=2) + " (%d)" % len(story), bt))
a(Paragraph("I should never be at the bottom of a frame (%d)" % len(story), h3))
a(Paragraph(randomText(theme=PYTHON, sentences=1) + " (%d)" % len(story), bt))
a(Paragraph("Now we do <br/> tests", h1))
a(Paragraph("First off no br tags", h3))
a(Paragraph(_text1, bt))
a(Paragraph("<br/> after 'the' in line 4", h3))
a(Paragraph(_text1.replace("forms of the", "forms of the<br/>", 1), bt))
a(Paragraph("2*<br/> after 'the' in line 4", h3))
a(Paragraph(_text1.replace("forms of the", "forms of the<br/><br/>", 1), bt))
a(Paragraph("<br/> after 'I suggested ' in line 5", h3))
a(Paragraph(_text1.replace("I suggested ", "I suggested<br/>", 1), bt))
a(Paragraph("2*<br/> after 'I suggested ' in line 5", h3))
a(Paragraph(_text1.replace("I suggested ", "I suggested<br/><br/>", 1), bt))
a(Paragraph("<br/> at the end of the paragraph!", h3))
a(Paragraph("""text one<br/>text two<br/>""", bt))
a(Paragraph("Border with <nr/> at the end of the paragraph!", h3))
bt1 = ParagraphStyle("bodyText1", bt)
bt1.borderWidth = 0.5
bt1.borderColor = colors.toColor("red")
bt1.backColor = colors.pink
bt1.borderRadius = 2
bt1.borderPadding = 3
a(Paragraph("""text one<br/>text two<br/>""", bt1))
a(Paragraph("Border no <nr/> at the end of the paragraph!", h3))
bt1 = ParagraphStyle("bodyText1", bt)
bt1.borderWidth = 0.5
bt1.borderColor = colors.toColor("red")
bt1.backColor = colors.pink
bt1.borderRadius = 2
bt1.borderPadding = 3
a(Paragraph("""text one<br/>text two""", bt1))
a(Paragraph("Different border style!", h3))
bt2 = ParagraphStyle("bodyText1", bt1)
bt2.borderWidth = 1.5
bt2.borderColor = colors.toColor("blue")
bt2.backColor = colors.gray
bt2.borderRadius = 3
bt2.borderPadding = 3
a(Paragraph("""text one<br/>text two<br/>""", bt2))
doc = MyDocTemplate(outputfile("test_platypus_breaking.pdf"))
doc.multiBuild(story)
示例10: to_pdf
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [as 别名]
def to_pdf(self, user, response):
def invoice_footer(canvas, doc):
canvas.saveState()
canvas.setFont('Times-Roman', 10)
PAGE_WIDTH = defaultPageSize[0]
footer_text = "%s %s - SIRET : %s - %s, %s %s" % (user.first_name,
user.last_name,
user.get_profile().company_id,
user.get_profile().address.street.replace("\n", ", ").replace("\r", ""),
user.get_profile().address.zipcode,
user.get_profile().address.city)
if user.get_profile().address.country:
footer_text = footer_text + u", %s" % (user.get_profile().address.country)
canvas.drawCentredString(PAGE_WIDTH / 2.0, 0.5 * inch, footer_text)
canvas.restoreState()
filename = ugettext('invoice_%(invoice_id)d.pdf') % {'invoice_id': self.invoice_id}
response['Content-Disposition'] = 'attachment; filename=%s' % (filename)
doc = BaseDocTemplate(response, title=ugettext('Invoice #%(invoice_id)d') % {'invoice_id': self.invoice_id}, leftMargin=0.5 * inch, rightMargin=0.5 * inch)
frameT = Frame(doc.leftMargin, doc.bottomMargin, doc.width, doc.height + 0.5 * inch, id='normal')
doc.addPageTemplates([PageTemplate(id='all', frames=frameT, onPage=invoice_footer), ])
styleH = ParagraphStyle({})
styleH.fontSize = 14
styleH.leading = 16
styleH.borderPadding = (5,) * 4
styleTotal = ParagraphStyle({})
styleTotal.fontSize = 14
styleTotal.leading = 16
styleTotal.borderColor = colors.black
styleTotal.borderWidth = 0.5
styleTotal.borderPadding = (5,) * 4
styleH2 = ParagraphStyle({})
styleH2.fontSize = 14
styleH2.leading = 16
styleTitle = ParagraphStyle({})
styleTitle.fontSize = 14
styleTitle.fontName = "Times-Bold"
styleN = ParagraphStyle({})
styleN.fontSize = 12
styleN.leading = 14
styleNSmall = ParagraphStyle({})
styleNSmall.fontSize = 8
styleNSmall.leading = 14
styleF = ParagraphStyle({})
styleF.fontSize = 10
styleF.alignment = TA_CENTER
styleLabel = ParagraphStyle({})
story = []
data = []
user_header_content = """
%s %s<br/>
%s<br/>
%s %s<br/>
%s<br/>
SIRET : %s<br/>
""" % (user.first_name,
user.last_name,
user.get_profile().address.street.replace("\n", "<br/>"),
user.get_profile().address.zipcode,
user.get_profile().address.city,
user.get_profile().address.country or '',
user.get_profile().company_id)
customer_header_content = """
%s<br/>
%s<br/>
%s %s<br/>
%s<br/>
"""
if user.get_profile().logo_file:
user_header = Image("%s%s" % (settings.FILE_UPLOAD_DIR, user.get_profile().logo_file))
else:
user_header = Paragraph(user_header_content, styleH)
customer_header = customer_header_content % (self.customer.name,
self.customer.address.street.replace("\n", "<br/>"),
self.customer.address.zipcode,
self.customer.address.city,
self.customer.address.country or '')
if self.customer.contact_type == CONTACT_TYPE_COMPANY \
and self.customer.company_id:
customer_header = "%sSIRET : %s<br/>" % (customer_header,
self.customer.company_id)
customer_header = Paragraph(customer_header, styleH)
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [as 别名]
def __init__(self, xoffset=0):
self.xoffset = xoffset
def wrap(self, *args):
return (self.xoffset, 0)
def draw(self):
canvas = self.canv
canvas.drawImage("centre2_8000_rotated.jpg", -10,-260, width=400,height=280)
# Create the styles for the document
logoStyle = ParagraphStyle('normal')
logoStyle.fontSize=16
logoStyle.leading=15
logoStyle.rightindent=5
logoStyle.backColor='grey'
#logoStyle.textColor='white'
logoStyle.borderWidth=5
logoStyle.borderColor='grey'
rightStyle = ParagraphStyle('normal')
rightStyle.alignment = TA_RIGHT
rightStyle.spaceBefore = 10
paraStyle = ParagraphStyle('normal')
paraStyle.spaceAfter = 10
paraStyle.alignment = TA_JUSTIFY
medStyle = ParagraphStyle('normal')
medStyle.fontSize = 8
medStyle.leading = 8
medStyle.spaceAfter = 10
medStyle.alignment = TA_JUSTIFY
示例12: createPDF
# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderWidth [as 别名]
#.........这里部分代码省略.........
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
description = ParagraphStyle('Description')
description.spaceBefore = 6
description.spaceAfter = 8
description.fontSize = 11
description.fontName = 'Helvetica-Bold'
description.leading = 13
padded_image = ParagraphStyle('PaddedImage')
padded_image.spaceBefore = 12
padded_image.spaceAfter = 12
single_line = ParagraphStyle('SingleLine')
single_line.fontSize = 9
single_line.fontName = 'Times-Roman'
single_line.spaceBefore = 0
single_line.spaceAfter = 0
single_line_cr = ParagraphStyle('SingleLineCR')
single_line_cr.fontSize = 9
single_line_cr.fontName = 'Times-Roman'
single_line_cr.spaceBefore = 0
single_line_cr.spaceAfter = 10