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


Python Paragraph.canv方法代码示例

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


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

示例1: beforeDrawPage

# 需要导入模块: from reportlab.platypus.paragraph import Paragraph [as 别名]
# 或者: from reportlab.platypus.paragraph.Paragraph import canv [as 别名]
    def beforeDrawPage(self,canvas,doc):
        canvas.setFont(serif_font,10)      
        canvas.setLineWidth(0)
        #header
        canvas.line(header_margin_hor, page_height - header_margin_vert, page_width - header_margin_hor, page_height - header_margin_vert )
        if pdfstyles.show_page_header:
            canvas.saveState()
            canvas.resetTransforms()
            canvas.translate(header_margin_hor, page_height - header_margin_vert - 0.1*cm)
            p = Paragraph(self.title, text_style())
            p.canv = canvas
            p.wrap(page_width - header_margin_hor*2.5, page_height) # add an extra 0.5 margin to have enough space for page number
            p.drawPara()
            canvas.restoreState()
            
        canvas.drawRightString(page_width - header_margin_hor, page_height - header_margin_vert + 0.1 * cm, "%d" % doc.page)

        #Footer
        canvas.saveState()
        canvas.setFont(serif_font,8)
        canvas.line(footer_margin_hor, footer_margin_vert, page_width - footer_margin_hor, footer_margin_vert )
        if pdfstyles.show_page_footer:
            p = Paragraph(formatter.cleanText(pagefooter, escape=False), text_style())
            p.canv = canvas
            w,h = p.wrap(page_width - header_margin_hor*2.5, page_height)
            p.drawOn(canvas, footer_margin_hor, footer_margin_vert - 10 - h)
        canvas.restoreState()
开发者ID:ingob,项目名称:mwlib.rl,代码行数:29,代码来源:pagetemplates.py

示例2: beforeDrawPage

# 需要导入模块: from reportlab.platypus.paragraph import Paragraph [as 别名]
# 或者: from reportlab.platypus.paragraph.Paragraph import canv [as 别名]
 def beforeDrawPage(self, canvas, doc):
     canvas.setFont(serif_font, 8)
     canvas.saveState()
     if pdfstyles.show_title_page_footer:
         canvas.line(footer_margin_hor, footer_margin_vert, page_width - footer_margin_hor, footer_margin_vert)
         footertext = [_(titlepagefooter)]
         if pdfstyles.show_creation_date:
             locale.setlocale(locale.LC_ALL, "")
             footertext.append(
                 pdfstyles.creation_date_txt % time.strftime(pdfstyles.creation_date_format, time.localtime())
             )
         lines = [formatter.cleanText(line, escape=False) for line in footertext]
         txt = "<br/>".join(line if isinstance(line, unicode) else unicode(line, "utf-8") for line in lines)
         p = Paragraph(txt, text_style(mode="footer"))
         w, h = p.wrap(print_width, print_height)
         canvas.translate((page_width - w) / 2.0, footer_margin_vert - h - 0.25 * cm)
         p.canv = canvas
         p.draw()
     canvas.restoreState()
     if self.cover:
         width, height = self._scale_img(pdfstyles.title_page_image_size, self.cover)
         if pdfstyles.title_page_image_pos[0] is None:
             x = (page_width - width) / 2.0
         else:
             x = max(0, min(page_width - width, pdfstyles.title_page_image_pos[0]))
         if pdfstyles.title_page_image_pos[1] is None:
             y = (page_height - height) / 2.0
         else:
             y = max(0, min(page_height - height, pdfstyles.title_page_image_pos[1]))
         canvas.drawImage(self.cover, x, y, width, height)
开发者ID:tosher,项目名称:mwlib.rl,代码行数:32,代码来源:pagetemplates.py

示例3: beforeDrawPage

# 需要导入模块: from reportlab.platypus.paragraph import Paragraph [as 别名]
# 或者: from reportlab.platypus.paragraph.Paragraph import canv [as 别名]
 def beforeDrawPage(self,canvas,doc):
     canvas.setFont(serif_font,8)
     canvas.saveState()
     if pdfstyles.show_title_page_footer:
         canvas.line(footer_margin_hor, footer_margin_vert, page_width - footer_margin_hor, footer_margin_vert )
         footertext = [_(titlepagefooter)]
         if pdfstyles.show_creation_date:
             footertext.append('PDF generated at: %s' % strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()))
         p = Paragraph('<br/>'.join([formatter.cleanText(line, escape=False) for line in footertext]),
                       text_style(mode='footer'))
         w,h = p.wrap(print_width, print_height)
         canvas.translate( (page_width-w)/2.0, footer_margin_vert - h - 0.25*cm)
         p.canv = canvas
         p.draw()
     canvas.restoreState()
     if self.cover:
         width, height = self._scale_img(pdfstyles.title_page_image_size, self.cover)
         if pdfstyles.title_page_image_pos[0] == None:
             x = (page_width - width) / 2.0
         else:
             x = max(0, min(page_width-width, pdfstyles.title_page_image_pos[0]))
         if pdfstyles.title_page_image_pos[1] == None:
             y = (page_height - height) / 2.0
         else:
             y = max(0, min(page_height-height, pdfstyles.title_page_image_pos[1]))
         canvas.drawImage(self.cover, x, y, width , height)
开发者ID:EtherGraf,项目名称:mwlib.rl,代码行数:28,代码来源:pagetemplates.py


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