本文整理汇总了Python中reportlab.lib.styles.getSampleStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:Python styles.getSampleStyleSheet方法的具体用法?Python styles.getSampleStyleSheet怎么用?Python styles.getSampleStyleSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.lib.styles
的用法示例。
在下文中一共展示了styles.getSampleStyleSheet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def __init__(self, cwd, output, version=''):
self.cwd = cwd
self.tag = os.path.basename(os.path.normpath(self.cwd))
self.version = version
self.story = []
stylesheet = getSampleStyleSheet()
self.title_style = stylesheet['Title']
self.heading_style = stylesheet['Heading2']
self.heading2_style = stylesheet['Heading3']
self.normal_style = stylesheet['Normal']
self.body_style = stylesheet['BodyText']
self.current_section = 0
self.doc = doc = SimpleDocTemplate(output,
pagesize=A4,
leftMargin=2.2*cm, rightMargin=2.2*cm,
topMargin=1.5*cm,bottomMargin=2.5*cm)
self.plot_width = self.doc.width * 0.85
self.plot_scale = 0.4
示例2: generate_style
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def generate_style(self, font_name=None, font_size=None):
super(MyPdfDocument, self).generate_style(font_name, font_size)
_styles = getSampleStyleSheet()
self.style.normal = copy.deepcopy(_styles['Normal'])
self.style.normal.alignment = 4
self.style.normal.fontName = '%s' % self.style.fontName
self.style.normal.fontSize = self.style.fontSize
self.style.normal.firstLineIndent = 0.4 * cm
self.style.normal.spaceBefore = self.style.fontSize * 1.5
# normal.textColor = '#0e2b58'
self.style.end_connection = copy.deepcopy(_styles['Normal'])
self.style.end_connection.alignment = 0
self.style.end_connection.fontName = '%s-Bold' % self.style.fontName
self.style.end_connection.fontSize = self.style.fontSize
self.style.end_connection.spaceBefore = self.style.fontSize * 3
self.style.table_header = copy.deepcopy(self.style.normal)
self.style.table_header.alignment = TA_CENTER
示例3: buildContext
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def buildContext(stylesheet=None):
result = {}
from reportlab.lib.styles import getSampleStyleSheet
if stylesheet is not None:
# Copy styles with the same name as aliases
for stylenamekey, stylenamevalue in DEFAULT_ALIASES.items():
if stylenamekey in stylesheet:
result[stylenamekey] = stylesheet[stylenamekey]
# Then make aliases
for stylenamekey, stylenamevalue in DEFAULT_ALIASES.items():
if stylenamevalue in stylesheet:
result[stylenamekey] = stylesheet[stylenamevalue]
styles = getSampleStyleSheet()
# Then, fill in defaults if they were not filled yet.
for stylenamekey, stylenamevalue in DEFAULT_ALIASES.items():
if stylenamekey not in result and stylenamevalue in styles:
result[stylenamekey] = styles[stylenamevalue]
return result
示例4: get_cover_page
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def get_cover_page(self, report_id, recipient):
# title = f"{self.report_title} No.: {report_id}"
styles = getSampleStyleSheet()
headline_style = styles["Heading1"]
headline_style.alignment = TA_CENTER
headline_style.fontSize = 48
subtitle_style = styles["Heading2"]
subtitle_style.fontSize = 24
subtitle_style.leading = 26
subtitle_style.alignment = TA_CENTER
CoverPage = []
logo = os.path.join(settings.BASE_DIR, self.logo_path)
image = Image(logo, 3 * inch, 3 * inch)
CoverPage.append(image)
CoverPage.append(Spacer(1, 18))
CoverPage.append(Paragraph("CONFIDENTIAL", headline_style))
# paragraph = Paragraph(
# f"Intended for: {recipient}, Title IX Coordinator", subtitle_style)
# CoverPage.append(paragraph)
CoverPage.append(PageBreak())
return CoverPage
# entrypoints
示例5: buildContext
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def buildContext(stylesheet=None):
result = {}
from reportlab.lib.styles import getSampleStyleSheet
if stylesheet is not None:
# Copy styles with the same name as aliases
for (stylenamekey, stylenamevalue) in DEFAULT_ALIASES.items():
if stylenamekey in stylesheet:
result[stylenamekey] = stylesheet[stylenamekey]
# Then make aliases
for (stylenamekey, stylenamevalue) in DEFAULT_ALIASES.items():
if stylenamevalue in stylesheet:
result[stylenamekey] = stylesheet[stylenamevalue]
styles = getSampleStyleSheet()
# Then, fill in defaults if they were not filled yet.
for (stylenamekey, stylenamevalue) in DEFAULT_ALIASES.items():
if stylenamekey not in result and stylenamevalue in styles:
result[stylenamekey] = styles[stylenamevalue]
return result
示例6: convertSourceFiles
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def convertSourceFiles(filenames):
"Helper function - makes minimal PDF document"
from reportlab.platypus import Paragraph, SimpleDocTemplate, Spacer, XPreformatted
from reportlab.lib.styles import getSampleStyleSheet
styT=getSampleStyleSheet()["Title"]
styC=getSampleStyleSheet()["Code"]
doc = SimpleDocTemplate("pygments2xpre.pdf")
S = [].append
for filename in filenames:
S(Paragraph(filename,style=styT))
src = open(filename, 'r').read()
fmt = pygments2xpre(src)
S(XPreformatted(fmt, style=styC))
doc.build(S.__self__)
print 'saved pygments2xpre.pdf'
示例7: __init__
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def __init__(self, doc_or_path, coverpage=None, pagesize=None, stylesheet=None, showBoundary=0):
self.path = None
if isinstance(doc_or_path, basestring):
self.path = doc_or_path
doc = self.build_doc(doc_or_path, pagesize=pagesize, showBoundary=showBoundary)
self.doc = doc
self.pagesize = doc.pagesize
self.width, self.height = self.pagesize
self.inc_cover = inc_coverpage = coverpage is not None
self.template_defs = {}
self.story = []
self.active_template_id = None
self.stylesheet = stylesheet or getSampleStyleSheet()
if inc_coverpage:
# Allow user to override the cover page template
if not self.get_page_template('cover', err=0):
f = Frame(0, 0, self.width, self.height)
pt = PageTemplate(id='cover', frames=[f], onPage=coverpage.onPage)
self.add_page_template(pt)
示例8: __init__
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def __init__(self, pdf_components):
self.style = getSampleStyleSheet()
self.style['Normal'].leading = 16
self.style.add(ParagraphStyle(name='centered', alignment=TA_CENTER))
self.style.add(ParagraphStyle(name='centered_wide', alignment=TA_CENTER,
leading=18))
self.style.add(ParagraphStyle(name='section_body',
parent=self.style['Normal'],
spaceAfter=inch * .05,
fontSize=11))
self.style.add(ParagraphStyle(name='bullet_list',
parent=self.style['Normal'],
fontSize=11))
if six.PY3:
self.buffer = six.BytesIO()
else:
self.buffer = six.StringIO()
self.firstPage = True
self.document = SimpleDocTemplate(self.buffer, pagesize=letter,
rightMargin=12.7 * mm, leftMargin=12.7 * mm,
topMargin=120, bottomMargin=80)
self.tlp_color = pdf_components.get('tlp_color', '')
self.pdf_components = pdf_components
self.pdf_list = []
示例9: __init__
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def __init__(self, invoice_path, pdf_info=None, precision='0.01'):
if not pdf_info:
pdf_info = self.default_pdf_info
SimpleDocTemplate.__init__(
self,
invoice_path,
pagesize=letter,
rightMargin=inch,
leftMargin=inch,
topMargin=inch,
bottomMargin=inch,
**pdf_info.__dict__
)
self.precision = precision
self._defined_styles = getSampleStyleSheet()
self._defined_styles.add(
ParagraphStyle('RightHeading1', parent=self._defined_styles.get('Heading1'), alignment=TA_RIGHT)
)
self._defined_styles.add(
ParagraphStyle('TableParagraph', parent=self._defined_styles.get('Normal'), alignment=TA_CENTER)
)
self.invoice_info = None
self.service_provider_info = None
self.client_info = None
self.is_paid = False
self._items = []
self._item_tax_rate = None
self._transactions = []
self._story = []
self._bottom_tip = None
self._bottom_tip_align = None
示例10: wrap
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def wrap(self,aW,aH):
value = self.get_value(aW,aH)
P = self.klass
if not P:
from reportlab.platypus.paragraph import Paragraph as P
style = self.style
if not style:
from reportlab.lib.styles import getSampleStyleSheet
style=getSampleStyleSheet()['Code']
if self.escape:
from xml.sax.saxutils import escape
value=escape(value)
self.add_content(P(value,style=style))
return 0,0
示例11: defaultContext
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def defaultContext():
result = {}
from reportlab.lib.styles import getSampleStyleSheet
styles = getSampleStyleSheet()
for stylenamekey, stylenamevalue in DEFAULT_ALIASES.items():
result[stylenamekey] = styles[stylenamevalue]
return result
示例12: convertSourceFiles
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def convertSourceFiles(filenames):
"Helper function - makes minimal PDF document"
from reportlab.platypus import Paragraph, SimpleDocTemplate, Spacer, XPreformatted
from reportlab.lib.styles import getSampleStyleSheet
styT=getSampleStyleSheet()["Title"]
styC=getSampleStyleSheet()["Code"]
doc = SimpleDocTemplate("pygments2xpre.pdf")
S = [].append
for filename in filenames:
S(Paragraph(filename,style=styT))
src = open(filename, 'r').read()
fmt = pygments2xpre(src)
S(XPreformatted(fmt, style=styC))
doc.build(S.__self__)
print('saved pygments2xpre.pdf')
示例13: __init__
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def __init__(self, invoice_path, pdf_info=None, precision='0.01'):
if not pdf_info:
pdf_info = self.default_pdf_info
SimpleDocTemplate.__init__(
self,
invoice_path,
pagesize=letter,
rightMargin=inch,
leftMargin=inch,
topMargin=inch,
bottomMargin=inch,
**pdf_info.__dict__
)
self.precision = precision
self._defined_styles = getSampleStyleSheet()
self._defined_styles.add(
ParagraphStyle('RightHeading1', parent=self._defined_styles.get('Heading1'), alignment=TA_RIGHT)
)
self._defined_styles.add(
ParagraphStyle('TableParagraph', parent=self._defined_styles.get('Normal'), alignment=TA_CENTER)
)
self.invoice_info = None
self.service_provider_info = None
self.client_info = None
self.is_paid = False
self._items = []
self._item_discount_rate = None
self._transactions = []
self._story = []
self._bottom_tip = None
self._bottom_tip_align = None
self._amount_recieved = None
示例14: headline_style
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def headline_style(self):
styles = getSampleStyleSheet()
headline_style = styles["Heading1"]
headline_style.alignment = TA_CENTER
headline_style.fontSize = 48
return headline_style
示例15: subtitle_style
# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import getSampleStyleSheet [as 别名]
def subtitle_style(self):
styles = getSampleStyleSheet()
subtitle_style = styles["Heading2"]
subtitle_style.fontSize = 24
subtitle_style.leading = 26
subtitle_style.alignment = TA_CENTER
return subtitle_style