diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-06 11:48:51 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-06 11:48:51 +0200 |
commit | 271f249c0ff24b593bcc83c86edfeb236a551be5 (patch) | |
tree | b141259d69a91486553048f9dddb7dbd168c045d /pdf-as-lib/src/main/java/at/gv/egiz | |
parent | a1faffc1987ee9a523b2736b7df5d6cb2fb5ca42 (diff) | |
download | pdf-as-4-271f249c0ff24b593bcc83c86edfeb236a551be5.tar.gz pdf-as-4-271f249c0ff24b593bcc83c86edfeb236a551be5.tar.bz2 pdf-as-4-271f249c0ff24b593bcc83c86edfeb236a551be5.zip |
Colum span handling corrected. #38
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz')
3 files changed, 30 insertions, 12 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java index 838d9d5a..939c2b3a 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java @@ -34,6 +34,7 @@ import java.util.Vector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsException; import at.gv.egiz.pdfas.common.settings.IProfileConstants; import at.gv.egiz.pdfas.common.settings.ISettings; import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings; @@ -97,12 +98,13 @@ public class TableFactory implements IProfileConstants { * @param tableID * is the name of the table definition in the settings file * @return a new abstract signature table + * @throws PdfAsSettingsException * @see at.knowcenter.wag.egov.egiz.table.Style * @see at.knowcenter.wag.egov.egiz.table.Table * @see at.knowcenter.wag.egov.egiz.table.Entry */ public static Table createSigTable(SignatureProfileSettings profile, String tableID, OperationStatus operationStatus, - ICertificateProvider certProvider) + ICertificateProvider certProvider) throws PdfAsSettingsException { String table_key_prefix = SIG_OBJ + profile.getProfileID() + "." + TABLE; String table_key = table_key_prefix + tableID; @@ -198,7 +200,7 @@ public class TableFactory implements IProfileConstants { resolver.resolve(key, value, profile), key); if (entry != null) { - //entry.setColSpan(2); + entry.setColSpan(2); entry.setStyle(defaultValueStyle_); row.add(entry); } @@ -212,7 +214,7 @@ public class TableFactory implements IProfileConstants { resolver.resolve(key, value, profile), key); if (entry != null) { - //entry.setColSpan(2); + entry.setColSpan(2); entry.setStyle(defaultCaptionStyle_); row.add(entry); } @@ -260,7 +262,7 @@ public class TableFactory implements IProfileConstants { sig_table.addRow(table_def, row); } } - + sig_table.normalize(); return sig_table; } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java index 38a883fe..e84bd498 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java @@ -197,9 +197,9 @@ public class PDFBoxTable { for (int j = 0; j < row.size(); j++) { Entry cell = (Entry) row.get(j); - float colWidth = colWidths[j]; + float colWidth = 0;//colWidths[j]; - int colsleft = cell.getColSpan() - 1; + int colsleft = cell.getColSpan(); if (j + colsleft > colWidths.length) { throw new IOException( diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java index bc21c266..88eb798a 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java @@ -93,23 +93,36 @@ public class TableDrawUtils { Style inherit_style = Style.doInherit(abstractTable.style, cell.getStyle()); cell.setStyle(inherit_style); + float colWidth = 0;//colWidths[j]; + + int colsleft = cell.getColSpan(); + + if (j + colsleft > colsSizes.length) { + throw new PdfAsException( + "Configuration is wrong. Cannot determine column width!"); + } + + for (int k = 0; k < colsleft; k++) { + colWidth = colWidth + colsSizes[j + k]; + } + drawDebugPadding(contentStream, contentx, contenty, padding, - colsSizes[j], abstractTable.getRowHeights()[i], settings); + colWidth, abstractTable.getRowHeights()[i], settings); switch (cell.getType()) { case Entry.TYPE_CAPTION: drawCaption(page, contentStream, contentx, contenty, - colsSizes[j], abstractTable.getRowHeights()[i], + colWidth, abstractTable.getRowHeights()[i], padding, abstractTable, doc, cell, formResources, settings); break; case Entry.TYPE_VALUE: drawValue(page, contentStream, contentx, contenty, - colsSizes[j], abstractTable.getRowHeights()[i], + colWidth, abstractTable.getRowHeights()[i], padding, abstractTable, doc, cell, formResources, settings); break; case Entry.TYPE_IMAGE: drawImage(page, contentStream, contentx, contenty, - colsSizes[j], abstractTable.getRowHeights()[i], + colWidth, abstractTable.getRowHeights()[i], padding, abstractTable, doc, cell, formResources, images, settings); break; @@ -122,7 +135,7 @@ public class TableDrawUtils { tbl_value.table.setStyle(inherit_styletab); drawTable(page, contentStream, contentx, contenty - - abstractTable.getRowHeights()[i], colsSizes[j], + - abstractTable.getRowHeights()[i], colWidth, abstractTable.getRowHeights()[i], tbl_value, doc, true, formResources, images, settings); break; @@ -132,7 +145,10 @@ public class TableDrawUtils { } // Move content pointer - contentx += colsSizes[j]; + contentx += colWidth; + + int span = cell.getColSpan() - 1; + j += span; } // Move content pointer |