PaidStamp
This commit is contained in:
parent
c8735377a6
commit
e40c392761
2 changed files with 13 additions and 3 deletions
|
@ -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()
|
2
test.py
2
test.py
|
@ -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))
|
||||||
|
|
Loading…
Reference in a new issue