Skip to content

Commit

Permalink
Fixed cell formats, again
Browse files Browse the repository at this point in the history
  • Loading branch information
katerina7479 committed Jan 29, 2014
1 parent a4e1211 commit e6c6aee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ v0.1.6, 01-23-2014 -- Rectangles print in the right direction.
v0.1.7, 01-23-2014 -- Added imports to __init__.py, make imports easier.
v0.1.8, 01-23-2014 -- Made it so \n works in text.
v0.1.9, 01-23-2014 -- Added page numbers.
v0.1.10, 01-29-2014 -- Fixed load_fonts & cellformats.
v0.1.10, 01-29-2014 -- Fixed load_fonts & cellformats.
v0.1.11, 01-29-2014 -- Fixed cellformats.
8 changes: 6 additions & 2 deletions pypdflite/pdfdocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,12 @@ def draw_table(self, table):
else:
raise Exception("Invalid Table")

def add_cell_format(self, data=None):
format = PDFCellFormat(data)
def add_cell_format(self, data=None, default_font=None):
if default_font is None:
default_font = self.font
if data is None:
data = {}
format = PDFCellFormat(data, default_font)
return format

def add_image(self, image=None, name=None):
Expand Down
6 changes: 3 additions & 3 deletions pypdflite/pdfobjects/pdfcellformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class PDFCellFormat(object):
in a dictionary of key / value pairs.
"""
def __init__(self, data=None):
def __init__(self, data, default_font):
self.dict = {}
self.available_keys = {'font': PDFFont(), # PDFFont
self.available_keys = {'font': default_font, # PDFFont
'num_format': None, # ('percent', #decimals), ('decimal', #d), ('money' or '$', #d), ('comma', #d), ('$comma' or 'money_comma') # Tuples
'align': "left", # Left, right, center
'valign': 'center', # Top, center, bottom
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self, data=None):
self._set_remaining()

def __repr__(self):
return "Format object, font %s" % self.dict['font']
return "Cell format object, font %s" % self.dict['font']

def __getitem__(self, key):
return self.dict[key]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='PyPDFLite',
version='0.1.10',
version='0.1.11',
author='Katerina Hanson',
author_email='[email protected]',
packages=['pypdflite', 'pypdflite.pdfobjects'],
Expand Down

0 comments on commit e6c6aee

Please sign in to comment.