aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java')
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java70
1 files changed, 25 insertions, 45 deletions
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
index a8a150e..3b9909f 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
@@ -35,6 +35,7 @@ import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import at.gv.egiz.pdfas.exceptions.ErrorCode;
+import at.gv.egiz.pdfas.utils.PDFASUtils;
import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
@@ -59,7 +60,7 @@ import com.lowagie.text.pdf.SubsetLocal;
* This class is the IText implementation of the PDFSignatureObject interface.
* The class takes an abstract definition of a signature object and convert them
* into a pdf table that is used to sign a pdf document.
- *
+ *
* @author wlackner
* @see at.knowcenter.wag.egov.egiz.sig.SignatureObject
* @see at.knowcenter.wag.egov.egiz.table.Table
@@ -76,8 +77,6 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
// 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";
-
/**
* The default font definition
*/
@@ -116,7 +115,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
/**
* The empty constructor. It loads the ui definitions from signature tables
* and init the align map.
- *
+ *
* @throws PDFDocumentException
*/
public PDFSignatureObjectIText() throws PDFDocumentException
@@ -127,7 +126,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
/**
* load the class settings
- *
+ *
* @throws PDFDocumentException
* @see SettingsReader
*/
@@ -174,7 +173,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
/**
* Set the abstract signature definition.
- *
+ *
* @param signatorObject
* the abstract signator object
* @see at.knowcenter.wag.egov.egiz.pdf.PDFSignatureObject#setSignatorObject(at.knowcenter.wag.egov.egiz.sig.SignatureObject)
@@ -186,7 +185,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
/**
* This method maps the table cell definitions to the pdfCell element.
- *
+ *
* @param pdfCell
* the pdf cell to be styled
* @param cellStyle
@@ -226,7 +225,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
align = ((Integer) alignMap_.get(cellStyle.getVAlign())).intValue();
if (align != -1)
pdfCell.setVerticalAlignment(align);
-
+
align = -1;
if (type == Entry.TYPE_VALUE && cellStyle.getValueHAlign() != null)
align = ((Integer) alignMap_.get(cellStyle.getValueHAlign())).intValue();
@@ -242,7 +241,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
/**
* This method maps the cell font definition to the iText Font Object
- *
+ *
* @param fontString
* @return the corresponding iText Font Object
* @see com.lowagie.text.Font
@@ -277,12 +276,12 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
int face = ((Integer) font_face).intValue();
float height = Float.parseFloat(font_arr[1]);
int weight = ((Integer) font_weight).intValue();
-
+
font = new Font(face, height, weight);
fontMap_.put(fontString, font);
return font;
}
-
+
/**
* Creates a custom
* @param fontString
@@ -305,15 +304,15 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
}
}
logger_.debug("TrueType Font detected:"+fontName +" ("+fontSize+")");
-
+
try {
Font font = (Font) fontMap_.get(fontString);
-
+
if (font == null) {
logger_.debug("Font \"" + fontString + "\" not in cache. Instantiating font.");
String fontPath = SettingsReader.RESOURCES_PATH + "fonts" + File.separator + fontName;
logger_.debug("Instantiating \"" + fontPath + "\".");
-
+
font = new Font(BaseFont.createFont(fontPath, BaseFont.WINANSI, true), fontSize);
fontMap_.put(fontString, font);
}
@@ -334,7 +333,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
* <li>images</li>
* <li>tables</li>
* </ul>
- *
+ *
* @param abstractCell
* the abstract cell definition
* @return the new redererd pdf table cell
@@ -345,27 +344,8 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
*/
private PdfPCell renderCell(Entry abstractCell) throws PDFDocumentException
{
- boolean pdfaValid =false;
- try
- {
- String profileid = sigObject_.getSignatureTypeDefinition().getType();
- String pdfa = SettingsReader.getInstance().getSetting("sig_obj." +profileid+".key."+SIG_PDFA1_B_VALID, "default."+SIG_PDFA1_B_VALID, "false");
- pdfaValid= "true".equalsIgnoreCase(pdfa);
-
-// exthex test
- //SubsetLocal.set(!pdfaValid);
-
-// boolean forceSubset = true; // get this from config, default to false
- //String
-
- //SubsetLocal.set(true); // exthex
-
- logger_.trace("Sign PDF/A compliant:"+pdfa);
- } catch (SettingsException e1)
- {
- logger_.error(e1);
- }
-
+ boolean pdfaValid = PDFASUtils.isPdfAEnabled(sigObject_.getSignatureTypeDefinition().getType());
+
PdfPCell pdf_cell = null;
Style cell_style = abstractCell.getStyle();
boolean isValue = true;
@@ -384,7 +364,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
{
font_string = cell_style.getValueFont();
}
-
+
logger_.trace("using cell font: "+font_string);
Font cell_font;
@@ -402,7 +382,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
}
// exthex
if (pdfaValid && abstractCell.getType() == Entry.TYPE_VALUE) {
- SubsetLocal.addNonSubsetFont(cell_font.getBaseFont());
+ SubsetLocal.addNonSubsetFont(cell_font.getBaseFont());
}
Phrase text_phrase = new Phrase(text, cell_font);
pdf_cell = new PdfPCell(text_phrase);
@@ -429,9 +409,9 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
}
Image image = Image.getInstance(img_file.getCanonicalPath());
logger_.debug("Using image file \"" + img_file.getCanonicalPath() + "\".");
-
+
image.scaleToFit(80.0f, 80.0f);
- boolean fit = true;
+ boolean fit = true;
Style.ImageScaleToFit istf = cell_style.getImageScaleToFit();
if (istf != null)
{
@@ -490,7 +470,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
* This method visualize an abstract table into a corresponding pdf table. The
* new pdf table is redered and get the style information from the abstract
* cell.
- *
+ *
* @param abstractTable
* the abstract table definition
* @return the new redererd pdf table cell
@@ -558,7 +538,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
/**
* This method creates the pdf table object. It takes the abstract table
* definition from the signature object and render the abstract table.
- *
+ *
* @param sigObject
* the signature object, the base for the abstract table definition
* @return R
@@ -587,7 +567,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
/**
* Converts the current abstract signature object in a pdf signature object
* implementation
- *
+ *
* @return the converted pdf signature object
* @see at.knowcenter.wag.egov.egiz.pdf.PDFSignatureObject#getSignatureObject()
*/
@@ -603,11 +583,11 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
/**
* Converts a abstract signature object in a pdf signature object
* implementation
- *
+ *
* @param sigObject
* the abstract signatorObject to convert
* @return the converted pdf signature object
- * @throws PDFDocumentException
+ * @throws PDFDocumentException
* @see at.knowcenter.wag.egov.egiz.pdf.PDFSignatureObject#getSignatureObject(at.knowcenter.wag.egov.egiz.sig.SignatureObject)
*/
public Object getSignatureObject(SignatureObject sigObject) throws PDFDocumentException