PaidStamp

This commit is contained in:
zhangshine 2015-05-30 21:15:47 +08:00
parent c8735377a6
commit e40c392761
2 changed files with 13 additions and 3 deletions

View file

@ -1,4 +1,7 @@
from reportlab.platypus import Paragraph, Table, TableStyle, Flowable from reportlab.graphics.charts.textlabels import Label
from reportlab.graphics.shapes import Drawing
from reportlab.lib.units import inch
from reportlab.platypus import Paragraph, Table, TableStyle
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.lib import colors from reportlab.lib import colors
@ -31,7 +34,14 @@ class PaidStamp(object):
self.y = y self.y = y
def __call__(self, canvas, doc): def __call__(self, canvas, doc):
# TODO: xxx # "PAID"
canvas.saveState() canvas.saveState()
canvas.setFontSize(50)
canvas.setFillColor(colors.red)
canvas.setStrokeColor(colors.red)
canvas.rotate(45)
canvas.drawString(self.x, self.y, 'PAID') canvas.drawString(self.x, self.y, 'PAID')
canvas.setLineWidth(4)
canvas.setLineJoin(1) # Round join
canvas.rect(self.x - .25 * inch, self.y - .25 * inch, width=2*inch, height=inch)
canvas.restoreState() canvas.restoreState()

View file

@ -22,4 +22,4 @@ story.append(merchant_table)
doc = SimpleInvoice('test.pdf') doc = SimpleInvoice('test.pdf')
doc.build(story, onFirstPage=PaidStamp(inch, 10*inch)) doc.build(story, onFirstPage=PaidStamp(7*inch, 5.8*inch))