當前位置: 首頁>>代碼示例>>Python>>正文


Python styles.getSampleStyleSheet方法代碼示例

本文整理匯總了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 
開發者ID:giesselmann,項目名稱:nanopype,代碼行數:20,代碼來源:report.py

示例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 
開發者ID:salan668,項目名稱:FAE,代碼行數:23,代碼來源:MyPDFDocument.py

示例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 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:21,代碼來源:para.py

示例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 
開發者ID:project-callisto,項目名稱:callisto-core,代碼行數:28,代碼來源:api.py

示例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 
開發者ID:gltn,項目名稱:stdm,代碼行數:21,代碼來源:para.py

示例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' 
開發者ID:gltn,項目名稱:stdm,代碼行數:18,代碼來源:pygments2xpre.py

示例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) 
開發者ID:bpsmith,項目名稱:tia,代碼行數:22,代碼來源:builder.py

示例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 = [] 
開發者ID:mitre,項目名稱:multiscanner,代碼行數:27,代碼來源:generic_pdf.py

示例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 
開發者ID:CiCiApp,項目名稱:PyInvoice,代碼行數:37,代碼來源:templates.py

示例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 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:16,代碼來源:flowables.py

示例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 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:9,代碼來源:para.py

示例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') 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:18,代碼來源:pygments2xpre.py

示例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 
開發者ID:104H,項目名稱:HH---POS-Accounting-and-ERP-Software,代碼行數:38,代碼來源:templates.py

示例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 
開發者ID:project-callisto,項目名稱:callisto-core,代碼行數:8,代碼來源:report_delivery.py

示例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 
開發者ID:project-callisto,項目名稱:callisto-core,代碼行數:9,代碼來源:report_delivery.py


注:本文中的reportlab.lib.styles.getSampleStyleSheet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。