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


Python Canvas.setPageRotation方法代码示例

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


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

示例1: create_prod_labels

# 需要导入模块: from reportlab.pdfgen.canvas import Canvas [as 别名]
# 或者: from reportlab.pdfgen.canvas.Canvas import setPageRotation [as 别名]
    def create_prod_labels(self):
        """
        These values should be measured from the printed page.
        In all the following calculations, the bottom left corner of
        the page is considered to be at the origin of the x-y plane.
        All the coordinates should be provided w.r.t. the this origin.
        """
        # page size
        page_H = 297*mm  # A4
        page_W = 210*mm   # A4
        # coordinates of lower left corner of single label w.r.t. origin
        box_X = 16.5*mm
        box_Y = 9.6*mm
        # distance between rows and columns of labels
        box_X_shift = 46.2*mm
        box_Y_shift = 36.0*mm

        pdfmetrics.registerFont(TTFont('Arial', 'ARIALN.TTF'))
        c = Canvas(self.outFile)
        c.setLineWidth(0.1)

        # horizontal lines
        for i in range(7):
            c.line(42*mm + i*box_Y_shift, 10*mm,
                   42*mm + i*box_Y_shift, page_W-10*mm)
        # vertical lines
        for i in range(3):
            c.line(2*mm, 58*mm + i*box_X_shift,
                   page_H-2*mm, 58*mm + i*box_X_shift)

        for i in range(4):
            dx = box_X + i*box_X_shift
            for j in range(8):
                dy = box_Y + j*box_Y_shift
                self.draw_single_label(dy, dx, c)

        c.setPageRotation(90)
        c.setPageSize((page_W, page_H))
        c.save()
        self.message.setText(
            "Creating " + self.outFile.replace(self.cdir, "Documents/"))
开发者ID:iyounus,项目名称:anaqa,代码行数:43,代码来源:anaqa.py


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