本文整理汇总了Python中rtfng.document.paragraph.Paragraph.append方法的典型用法代码示例。如果您正苦于以下问题:Python Paragraph.append方法的具体用法?Python Paragraph.append怎么用?Python Paragraph.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rtfng.document.paragraph.Paragraph
的用法示例。
在下文中一共展示了Paragraph.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_paraTabs
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_paraTabs():
doc, section, styles = RTFTestCase.initializeDoc()
p = Paragraph()
p.append(
"The paragraph itself can also be overridden in lots of ways: "
"tabs, borders, alignment, etc., can all be modified either in "
"the style or as an override during the creation of the "
"paragraph. This is demonstrated below with custom tab widths "
"and embedded carriage returns (i.e., new line markers that do "
"not cause a paragraph break)."
)
section.append(p)
tabs = [
TabPropertySet(width=TabPropertySet.DEFAULT_WIDTH),
TabPropertySet(width=TabPropertySet.DEFAULT_WIDTH * 2),
TabPropertySet(width=TabPropertySet.DEFAULT_WIDTH),
]
para_props = ParagraphPropertySet(tabs=tabs)
p = Paragraph(styles.ParagraphStyles.Normal, para_props)
p.append(
"Phrase at Left Tab",
TAB,
"Middle Phrase One",
TAB,
"Right Phrase",
LINE,
"Second Left Phrase",
TAB,
"Middle Phrase Two",
TAB,
"Another Right Phrase",
)
section.append(p)
return doc
示例2: make_headerFooterDiffPages
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_headerFooterDiffPages():
doc = Document()
ss = doc.StyleSheet
section = Section()
doc.Sections.append( section )
section.FirstHeader.append( 'This is the header for the first page.' )
section.FirstFooter.append( 'This is the footer for the first page.' )
section.Header.append( 'This is the header that will appear on subsequent pages.' )
section.Footer.append( 'This is the footer that will appear on subsequent pages.' )
p = Paragraph( ss.ParagraphStyles.Heading1 )
p.append( 'Example 6' )
section.append( p )
# blank paragraphs are just empty strings
section.append( '' )
p = Paragraph( ss.ParagraphStyles.Normal )
p.append( 'This document has different headers and footers for the first and then subsequent pages. '
'If you insert a page break you should see a different header and footer.' )
section.append( p )
return doc
示例3: test_CustomElementInsidePara
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def test_CustomElementInsidePara(self):
# It's just too hard to write a standard test with a custom renderer.
doc, section, styles = RTFTestCase.initializeDoc()
p = Paragraph()
p.append('This is a standard paragraph with the default style.')
class CustomClass(object):
pass
p.append(CustomClass())
section.append(p)
# Define renderer with custom element support.
specialString = "ABC I'm unique"
def customElementWriter(renderer, element):
renderer._write(specialString)
r = Renderer(write_custom_element_callback=customElementWriter)
# Render with custom element.
result = StringIO()
r.Write(doc, result)
testData = result.getvalue()
result.close()
# Confirm generate result has custom rendering.
assert specialString in testData
示例4: make_charFrame
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_charFrame():
doc, section, styles = RTFTestCase.initializeDoc()
p = Paragraph()
thinEdge = BorderPropertySet(width=20, style=BorderPropertySet.SINGLE, colour=styles.Colours.Blue)
textWithFrame = TextPropertySet(frame=thinEdge)
p.append(Text('This tests frame drawn around text.', textWithFrame))
section.append(p)
return doc
示例5: addConsultationBox
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def addConsultationBox(self, section, document):
""" Add the consultation box that needs to be signed by the employer
and workers.
"""
ss = document.StyleSheet
styles = document.StyleSheet.ParagraphStyles
thin_edge = BorderPropertySet(width=20, style=BorderPropertySet.SINGLE)
t = lambda txt: "".join([
"\u%s?" % str(ord(e)) for e in translate(txt, context=self.request)
])
table = Table(9500)
thin_edge = BorderPropertySet(width=20, style=BorderPropertySet.SINGLE)
no_edge = BorderPropertySet(width=0, colour=ss.Colours.White)
p = Paragraph(
styles.Heading3,
ParagraphPropertySet(alignment=ParagraphPropertySet.CENTER),
t(_("header_oira_report_consultation",
default="Consultation of workers"))
)
c = Cell(p, FramePropertySet(thin_edge, thin_edge, no_edge, thin_edge))
table.AddRow(c)
p = Paragraph(
styles.Normal,
ParagraphPropertySet(alignment=ParagraphPropertySet.LEFT),
t(_("paragraph_oira_consultation_of_workers",
default="The undersigned hereby declare that the workers "
"have been consulted on the content of this "
"document.")),
LINE
)
c = Cell(p, FramePropertySet(no_edge, thin_edge, no_edge, thin_edge))
table.AddRow(c)
p = Paragraph(
styles.Normal,
ParagraphPropertySet(alignment=ParagraphPropertySet.LEFT),
)
employer = t(_("oira_consultation_employer",
default="On behalf of the employer:"))
workers = t(_("oira_consultation_workers",
default="On behalf of the workers:"))
p.append(employer, TAB, TAB, TAB, TAB, workers, LINE, LINE)
c = Cell(p, FramePropertySet(no_edge, thin_edge, no_edge, thin_edge))
table.AddRow(c)
p = Paragraph(
ParagraphPropertySet(alignment=ParagraphPropertySet.LEFT),
t(_("oira_survey_date", default="Date:")),
LINE, LINE
)
c = Cell(p, FramePropertySet(no_edge, thin_edge, thin_edge, thin_edge))
table.AddRow(c)
section.append(table)
示例6: make_paraNormal
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_paraNormal():
doc, section, styles = RTFTestCase.initializeDoc()
p1 = Paragraph(styles.ParagraphStyles.Heading1)
p1.append('Heading 1')
section.append(p1)
p2 = Paragraph(styles.ParagraphStyles.Normal)
p2.append(
'In this case we have used two styles. The first paragraph is '
'marked with the Heading1 style, and this one is marked with the '
'Normal style.')
section.append(p2)
return doc
示例7: make_hyperlinks
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_hyperlinks():
doc, section, styles = RTFTestCase.initializeDoc()
p = Paragraph()
p.append('This is a standard paragraph with the default style.')
p = Paragraph()
p.append('This is also a standard paragraph. ',
'But lets add a ',
TEXT('Washington Post', hyperlink='https://washingtonpost.com'),
' hyperlink to this paragraph. ',
)
section.append(p)
return doc
示例8: make_charStyleOverride
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_charStyleOverride():
doc, section, styles = RTFTestCase.initializeDoc()
p = Paragraph()
p.append('This is a standard paragraph with the default style.')
p = Paragraph()
p.append('It is also possible to manully override a style. ',
'This is a change of just the font ',
TEXT('size', size=48),
' an this is for just the font ',
TEXT('typeface', font=styles.Fonts.Impact) ,
'.')
section.append(p)
return doc
示例9: make_charUnicode
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_charUnicode():
doc, section, styles = RTFTestCase.initializeDoc()
section.append('This tests unicode.')
p = Paragraph()
p.append(u'32\u00B0 Fahrenheit is 0\u00B0 Celsuis')
section.append(p)
p = Paragraph()
p.append(u'Henry \u2163 is Henry IV in unicode.')
section.append(p)
return doc
示例10: addIdentificationResults
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def addIdentificationResults(self, document):
survey = self.request.survey
section = createIdentificationReportSection(
document, self.context, self.request)
styles = document.StyleSheet.ParagraphStyles
header_styles = {
0: styles.Heading2,
1: styles.Heading3,
2: styles.Heading4,
3: styles.Heading5,
4: styles.Heading6,
}
for node in self.getNodes():
section.append(
Paragraph(
header_styles.get(node.depth, styles.Heading6),
u"%s %s" % (node.number, node.title))
)
if node.type != "risk":
continue
zodb_node = survey.restrictedTraverse(node.zodb_path.split("/"))
section.append(
Paragraph(
styles.Normal,
utils.html_unescape(
htmllaundry.StripMarkup(zodb_node.description))
)
)
for i in range(0, 8):
p = Paragraph(styles.Normal, " ")
section.append(p)
tabs = TabPropertySet(
section.TwipsToRightMargin(),
alignment=TabPropertySet.RIGHT,
leader=getattr(TabPropertySet, 'UNDERLINE')
)
p = Paragraph(styles.Normal, ParagraphPropertySet(tabs=[tabs]))
p.append(TAB)
section.append(p)
if node.comment and node.comment.strip():
section.append(Paragraph(styles.Comment, node.comment))
示例11: make_charInline
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_charInline():
doc, section, styles = RTFTestCase.initializeDoc()
p = Paragraph()
p.append(Inline('Simple Inline Element'))
section.append(p)
# Test various element types inside Inline element.
p = Paragraph()
p.append(Inline('First Inline Element',
TAB,
'Second Inline Element',
RawCode(r'\tab '),
'After tab'
))
section.append(p)
return doc
示例12: make_spaceBetweenLines
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_spaceBetweenLines():
doc, section, styles = RTFTestCase.initializeDoc()
para_props = ParagraphPropertySet()
quarterInch = 1440 / 2
para_props.SetSpaceBetweenLines(quarterInch)
p = Paragraph(para_props)
p.append("Paragraph One", LINE, "Second line", LINE, "Third line")
section.append(p)
para_props = ParagraphPropertySet()
para_props.SetSpaceBetweenLines(-quarterInch)
p = Paragraph(para_props)
p.append("Paragraph Two", LINE, "Second line", LINE, "Third line")
section.append(p)
return doc
示例13: export
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def export(self, tempdir):
self.outpath = os.path.join(tempdir, 'export.rtf')
self.imgnum = 1
doc = Document()
self.ss = doc.StyleSheet
export_title = u'Export (%d records)' % len(self.objs)
on_empty_page = True
if self.custom_order:
emitter = self.custom_emit_fields
else:
emitter = self.record_emit_fields
count = 0
size = len(self.objs)
while len(self.objs) > 0:
count += 1
yield "Formatting record %d of %d" % (count, size)
r = self.objs.pop(0)
if on_empty_page:
section = Section()
else:
section = Section(break_type=Section.PAGE)
on_empty_page = False
p = Paragraph(self.ss.ParagraphStyles.Heading1)
p.append(r.title)
section.append(p)
for p in self.emit_paragraphs(r, emitter(r)):
section.append(p)
if len(section) > 0:
doc.Sections.append(section)
fd = open(self.outpath, "wb")
doc.write(fd)
fd.close()
示例14: make_headerFooterSimple
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_headerFooterSimple():
doc = Document()
ss = doc.StyleSheet
section = Section()
doc.Sections.append( section )
section.Header.append( 'This is the header' )
section.Footer.append( 'This is the footer' )
p = Paragraph( ss.ParagraphStyles.Heading1 )
p.append( 'Example 5' )
section.append( p )
# blank paragraphs are just empty strings
section.append( '' )
p = Paragraph( ss.ParagraphStyles.Normal )
p.append( 'This document has a header and a footer.' )
section.append( p )
return doc
示例15: make_charTab
# 需要导入模块: from rtfng.document.paragraph import Paragraph [as 别名]
# 或者: from rtfng.document.paragraph.Paragraph import append [as 别名]
def make_charTab():
doc, section, styles = RTFTestCase.initializeDoc()
p = Paragraph()
p.append('Before tab')
p.append(Text(TAB))
p.append('After tab')
section.append(p)
return doc