python 基础教程第21章

#!/usr/bin/env python
# -*- coding = utf-8  -*
#一个简单的ReportLab程序


from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics import renderPDF


d = Drawing(100, 100)#Drawing生成一个给定大小的图纸
#创建带有某些属性的图形元素,本例是一个String对象它的主要参数是x y的坐标以及要显示的文本,
#还可以提供各种特性
s = String(50, 50, 'Hello, World!', textAnchor='middle',Color = 'blue')#textAnchor可选值为start middle end


d.add(s)#将元素添加到图纸中去


renderPDF.drawToFile(d, '/home/buntu/py5/items21.pdf', 'A simple PDF dile')

# renderPDF.drawToFile的调用会把你的PDF文件存到你指定的目录中

#函数文档介绍 drawToFile(d, fn, msg='', showBoundary=<reportlab.rl_config._unset_ object at 0x7f3bd5f01470>, autoSize=1)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值