diff --git a/ChangeLog b/ChangeLog index 0ee8d303c..d4548d3f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-04-07 Brian Matherly + * src/docgen/PdfDoc.py: fix columns, error check images + * src/docgen/RTFDoc.py: error check images + 2006-04-07 Don Allingham * src/EditPerson.py: Fix call to EditName, pylint fixes diff --git a/src/docgen/PdfDoc.py b/src/docgen/PdfDoc.py index 0c63449f0..f9a2fed56 100644 --- a/src/docgen/PdfDoc.py +++ b/src/docgen/PdfDoc.py @@ -243,6 +243,13 @@ class PdfDoc(BaseDoc.BaseDoc): self.text = "" def end_table(self): + # Calculate optimal widths + self.cur_table_cols = [] + width = float(self.cur_table.get_width()/100.0) * self.get_usable_width() + for val in range(self.cur_table.get_columns()): + percent = float(self.cur_table.get_column_width(val))/100.0 + self.cur_table_cols.append(int(width * percent * cm)) + ts = reportlab.platypus.tables.TableStyle(self.tblstyle) tbl = reportlab.platypus.tables.Table(data=self.table_data, colWidths=self.cur_table_cols, @@ -255,10 +262,6 @@ class PdfDoc(BaseDoc.BaseDoc): self.col = 0 self.cur_row = [] self.cur_table_cols = [] - width = float(self.cur_table.get_width()/100.0) * self.get_usable_width() - for val in range(self.cur_table.get_columns()): - percent = float(self.cur_table.get_column_width(val))/100.0 - self.cur_table_cols.append(int(width * percent * cm)) def end_row(self): self.table_data.append(self.cur_row) @@ -274,12 +277,9 @@ class PdfDoc(BaseDoc.BaseDoc): else: self.cur_row.append("") - the_width = self.cur_table_cols[self.col] + # Fill in cells that this cell spans over for val in range(1,self.span): self.cur_row.append("") - the_width += self.cur_table_cols[self.col+val] - self.cur_table_cols[self.col+val] = 0 - self.cur_table_cols[self.col] = the_width p = self.my_para f = p.get_font() @@ -317,6 +317,14 @@ class PdfDoc(BaseDoc.BaseDoc): self.tblstyle.append(('ALIGN', loc, loc, 'CENTER')) self.tblstyle.append(('VALIGN', loc, loc, 'TOP')) + # The following lines will enable the span feature. + # This is nice, except when spanning, lines that would have overfilled + # their cells still increase the height of the cell to make room for the + # wrapped text (even though the text does not actually wrap because it + # is spanned) + #if self.span != 1: + # self.tblstyle.append(('SPAN', (self.col, self.row), (self.col + self.span - 1, self.row ) )) + self.col = self.col + self.span self.text = "" @@ -328,6 +336,9 @@ class PdfDoc(BaseDoc.BaseDoc): x,y = img.size() + if (x,y) == (0,0): + return + ratio = float(x_cm)*float(y)/(float(y_cm)*float(x)) if ratio < 1: diff --git a/src/docgen/RTFDoc.py b/src/docgen/RTFDoc.py index abd4cbd2d..0ee363e65 100644 --- a/src/docgen/RTFDoc.py +++ b/src/docgen/RTFDoc.py @@ -349,6 +349,9 @@ class RTFDoc(BaseDoc.BaseDoc): nx,ny = im.size() + if (nx,ny) == (0,0): + return + ratio = float(x_cm)*float(ny)/(float(y_cm)*float(nx)) if ratio < 1: