Simple address table

This commit is contained in:
zhangshine 2015-05-28 01:09:44 +08:00
parent 6fbce729b4
commit bffdbd2671
3 changed files with 36 additions and 1 deletions

View file

@ -12,4 +12,9 @@ class CodeSnippet(Paragraph):
) )
def __init__(self, code): def __init__(self, code):
Paragraph.__init__(self, code, self.style) Paragraph.__init__(self, code, self.style)
class AddressTable(Table):
def __init__(self, data, horizontal_align=None):
Table.__init__(self, data, hAlign=horizontal_align)

16
pyinvoice/templates.py Normal file
View file

@ -0,0 +1,16 @@
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import inch
from reportlab.platypus import SimpleDocTemplate
class SimpleInvoice(SimpleDocTemplate):
def __init__(self, invoice_path):
SimpleDocTemplate.__init__(
self,
invoice_path,
pagesize=letter,
rightMargin=.25 * inch,
leftMargin=.25 * inch,
topMargin=.25 * inch,
bottomMargin=.25 * inch
)

14
test.py Normal file
View file

@ -0,0 +1,14 @@
from pyinvoice.components import AddressTable
from pyinvoice.templates import SimpleInvoice
story = []
address_table = AddressTable([
['Name', 'zhangshine'],
['City', 'Jining']
], horizontal_align='RIGHT')
story.append(address_table)
doc = SimpleInvoice('test.pdf')
doc.build(story)