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


Python Image._restrictSize方法代码示例

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


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

示例1: fill_sender

# 需要导入模块: from reportlab.platypus.flowables import Image [as 别名]
# 或者: from reportlab.platypus.flowables.Image import _restrictSize [as 别名]
 def fill_sender(self):
     """Fills sender identity"""
     from reportlab.platypus.flowables import Image
     from core.pdf.utils import Paragraph
     # Sender identity
     sender_paragraphs = []
     if self.invoice_base.current_revision.sender:
         sender_paragraphs.append(Paragraph(self.invoice_base.current_revision.sender, self.style['Small']))
     sender_paragraphs.append(Paragraph(self.invoice_base.tenant.name, self.style['Small']))
     if self.invoice_base.current_revision.sender_address:
         sender_paragraphs.append(Paragraph(u'\n'.join(self.invoice_base.current_revision.sender_address.get_formatted()), self.style['Small']))
     # Add layout table if logo or paragraphs
     if self.invoice_base.tenant.logo_cache:
         logo = Image(self.invoice_base.tenant.logo_cache)
         logo_width, logo_height = logo._restrictSize(50*mm, 20*mm)
         self.table(
             [[logo, sender_paragraphs]],
             (logo_width + 4*mm, None),
             self.style['LayoutTable'],
             rowHeights=(20*mm,)
         )
     else:
         for paragraph in sender_paragraphs:
             self.append(paragraph)
开发者ID:FacturaVirtual,项目名称:vosae-app,代码行数:26,代码来源:invoice_base.py

示例2: fill

# 需要导入模块: from reportlab.platypus.flowables import Image [as 别名]
# 或者: from reportlab.platypus.flowables.Image import _restrictSize [as 别名]
    def fill(self):
        from django.template.defaultfilters import date as format_date, floatformat
        from reportlab.platypus.flowables import Image
        from core.pdf.utils import Paragraph
        from invoicing import currency_format

        # Sender frame
        # Sender identity
        sender_paragraphs = []
        if self.invoice_base.current_revision.sender:
            sender_paragraphs.append(Paragraph(self.invoice_base.current_revision.sender, self.style['Small']))
        sender_paragraphs.append(Paragraph(self.invoice_base.tenant.name, self.style['Small']))
        if self.invoice_base.current_revision.sender_address:
            sender_paragraphs.append(Paragraph(u'\n'.join(self.invoice_base.current_revision.sender_address.get_formatted()), self.style['Small']))
        # Add layout table if logo or paragraphs
        if self.invoice_base.tenant.logo_cache:
            logo = Image(self.invoice_base.tenant.logo_cache)
            logo_width, logo_height = logo._restrictSize(50 * mm, 20 * mm)
            self.table(
                [[logo, sender_paragraphs]],
                (logo_width + 4 * mm, None),
                self.style['LayoutTable'],
                rowHeights=(20 * mm,)
            )
        else:
            for paragraph in sender_paragraphs:
                self.append(paragraph)

        # Billing address frame
        self.next_frame()
        if self.invoice_base.current_revision.contact:
            self.p(self.invoice_base.current_revision.contact.get_full_name(upper_name=True), style=self.style['Address'])
        if self.invoice_base.current_revision.organization:
            self.p(self.invoice_base.current_revision.organization.corporate_name, style=self.style['Address'])
        if self.invoice_base.current_revision.billing_address:
            self.p(u'\n'.join(self.invoice_base.current_revision.billing_address.get_formatted()), style=self.style['Address'])

        # Delivery address frame
        self.next_frame()
        if self.invoice_base.current_revision.contact:
            self.p(self.invoice_base.current_revision.contact.get_full_name(upper_name=True), style=self.style['Address'])
        if self.invoice_base.current_revision.organization:
            self.p(self.invoice_base.current_revision.organization.corporate_name, style=self.style['Address'])
        if self.invoice_base.current_revision.delivery_address:
            self.p(u'\n'.join(self.invoice_base.current_revision.delivery_address.get_formatted()), style=self.style['Address'])

        # Rest of the report
        self.next_frame()
        invoice_reference = pgettext('date', 'Undefined') if getattr(self.invoice_base, 'has_temporary_reference', None) else self.invoice_base.reference
        self.table([[
            ' '.join([unicode(self.invoice_base.RECORD_NAME).upper(), invoice_reference]),
            format_date(self.invoice_base.current_revision.invoicing_date, 'DATE_FORMAT')
        ]], (12 * cm, 5 * cm), style=self.style['InvoiceBaseReferencesTable'])

        self.spacer()
        rows = [[
            pgettext('table-headers', 'Description'),
            pgettext('table-headers', 'Qty'),
            pgettext('table-headers', 'Unit price (excl. tax)'),
            pgettext('table-headers', 'Tax'),
            pgettext('table-headers', 'Total (excl. tax)')
        ]]
        for item in self.invoice_base.current_revision.line_items:
            rows.append([
                item.description,
                floatformat(item.quantity, -2),
                currency_format(item.unit_price),
                '{0:.2%}'.format(item.tax.rate),
                currency_format(item.total_price, self.invoice_base.current_revision.currency.symbol)
            ])
        col_widths = (85 * mm, 20 * mm, 20 * mm, 20 * mm, 25 * mm)
        self.table(rows, col_widths, repeatRows=1, style=self.style['InvoiceBaseItemsTable'])

        self.spacer()
        rows = [[
            _('TOTAL (excl. tax)'),
            currency_format(self.invoice_base.sub_total, self.invoice_base.current_revision.currency.symbol)
        ]]
        for tax in self.invoice_base.taxes_amounts:
            rows.append([
                '%(tax_name)s (%(tax_rate)s)' % {
                    'tax_name': tax.get('name'),
                    'tax_rate': '{0:.2%}'.format(tax.get('rate'))
                },
                currency_format(tax.get('amount'), self.invoice_base.current_revision.currency.symbol)
            ])
        rows.append([
            _('TOTAL (incl. tax)'),
            currency_format(self.invoice_base.amount, self.invoice_base.current_revision.currency.symbol)
        ])
        col_widths = (None, 25 * mm)
        self.start_keeptogether()
        self.table(rows, col_widths, hAlign='RIGHT', style=self.style['InvoiceBaseSummaryTable'])
        self.end_keeptogether()

        # Legal notices
        self.spacer()
        self.start_keeptogether()
        if self.invoice_base.is_quotation():
            self.p(_("Valid until %(quotation_validity)s") % {
#.........这里部分代码省略.........
开发者ID:peicheng,项目名称:vosae-app,代码行数:103,代码来源:default.py


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