From 89a45b322b16d3c3a949b552f4fb4f07f2914817 Mon Sep 17 00:00:00 2001 From: pdanner Date: Thu, 4 Nov 2010 16:35:10 +0000 Subject: - Added image[valign|halign] config parameters to allow separate alignment of images. - Normalization of value cell values does not remove multiple newlines any more git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@601 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/pdf/PDFSignatureObjectIText.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/pdf') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java index 85abd73..5c1cddb 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java @@ -66,6 +66,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject // 03.11.2010 changed by exthex to allow setting separate hAlign and vAlign for value and non-value cells. // If no value for valuevalign or valuehalign is set the values from valign and halign are taken. // Also fixed a minor bug which prevented proper style inheritment (Bug Nr. #534). +// 04.11.2010 changed by exthex - allow setting separate hAlign and vAlign for image cells analog to value cells. private static final String SIG_PDFA1_B_VALID = "SIG_PDFA1B_VALID"; @@ -182,12 +183,12 @@ public class PDFSignatureObjectIText implements PDFSignatureObject * the pdf cell to be styled * @param cellStyle * the abstract style definition - * @param isValue - * true if the pdfCell is a value cell - the appropriate style will be set + * @param type + * type of the cell to render - the appropriate style will be set * @see com.lowagie.text.pdf.PdfPCell * @see at.knowcenter.wag.egov.egiz.table.Style */ - private void setCellStyle(PdfPCell pdfCell, Style cellStyle, boolean isValue) + private void setCellStyle(PdfPCell pdfCell, Style cellStyle, int type) { if (cellStyle != null) { @@ -205,16 +206,20 @@ public class PDFSignatureObjectIText implements PDFSignatureObject pdfCell.setBorder(0); } int align = -1; - if (isValue && cellStyle.getValueVAlign() != null) + if (type == Entry.TYPE_VALUE && cellStyle.getValueVAlign() != null) align = ((Integer) alignMap_.get(cellStyle.getValueVAlign())).intValue(); + else if (type == Entry.TYPE_IMAGE && cellStyle.getImageVAlign() != null) + align = ((Integer) alignMap_.get(cellStyle.getImageVAlign())).intValue(); else if (cellStyle.getVAlign() != null) align = ((Integer) alignMap_.get(cellStyle.getVAlign())).intValue(); if (align != -1) pdfCell.setVerticalAlignment(align); align = -1; - if (isValue && cellStyle.getValueHAlign() != null) + if (type == Entry.TYPE_VALUE && cellStyle.getValueHAlign() != null) align = ((Integer) alignMap_.get(cellStyle.getValueHAlign())).intValue(); + else if (type == Entry.TYPE_IMAGE && cellStyle.getImageHAlign() != null) + align = ((Integer) alignMap_.get(cellStyle.getImageHAlign())).intValue(); else if (cellStyle.getHAlign() != null) align = ((Integer) alignMap_.get(cellStyle.getHAlign())).intValue(); if (align != -1) @@ -375,7 +380,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject } Phrase text_phrase = new Phrase(text, cell_font); pdf_cell = new PdfPCell(text_phrase); - setCellStyle(pdf_cell, cell_style, isValue); + setCellStyle(pdf_cell, cell_style, (isValue?Entry.TYPE_VALUE:Entry.TYPE_CAPTION)); break; case Entry.TYPE_IMAGE: try @@ -408,7 +413,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject fit = false; } pdf_cell = new PdfPCell(image, fit); - setCellStyle(pdf_cell, cell_style, false); + setCellStyle(pdf_cell, cell_style, Entry.TYPE_IMAGE); } catch (BadElementException e) { @@ -490,7 +495,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject pdf_table = new PdfPTable(cols); pdf_table.setWidthPercentage(abstractTable.getWidth()); Style table_style = abstractTable.getStyle(); - setCellStyle(pdf_table.getDefaultCell(), table_style, false); + setCellStyle(pdf_table.getDefaultCell(), table_style, Entry.TYPE_TABLE); ArrayList rows = abstractTable.getRows(); for (int row_idx = 0; row_idx < rows.size(); row_idx++) -- cgit v1.2.3