aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2008-11-25 12:52:47 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2008-11-25 12:52:47 +0000
commitc2dc72bc99b99959dce84466c5723894169e07b5 (patch)
tree82f0c305d5067c3255fcf9a3787a23608af00259
parentea60aae139c666c610c1af5cfd0b616d3f4a535c (diff)
downloadpdf-as-3-c2dc72bc99b99959dce84466c5723894169e07b5.tar.gz
pdf-as-3-c2dc72bc99b99959dce84466c5723894169e07b5.tar.bz2
pdf-as-3-c2dc72bc99b99959dce84466c5723894169e07b5.zip
Minor support for TrueType fonts in preparation of PDF/A added.
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@313 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
-rw-r--r--pom.xml8
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java35
-rw-r--r--src/site/changes.xml1
3 files changed, 35 insertions, 9 deletions
diff --git a/pom.xml b/pom.xml
index d7b709b..fa6c239 100644
--- a/pom.xml
+++ b/pom.xml
@@ -301,14 +301,6 @@
<version>2.3</version>
</dependency>
- <!-- nur falls die default configuration mittels commons-vfs extrahiert wird
- <dependency>
- <groupId>commons-vfs</groupId>
- <artifactId>commons-vfs</artifactId>
- <version>1.0</version>
- </dependency>
- -->
-
<!-- iText -->
<dependency>
<groupId>com.lowagie</groupId>
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 75e90c5..5bc748d 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
@@ -26,6 +26,7 @@ import java.util.HashMap;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
+import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
@@ -36,10 +37,12 @@ import at.knowcenter.wag.egov.egiz.table.Style;
import at.knowcenter.wag.egov.egiz.table.Table;
import com.lowagie.text.BadElementException;
+import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.Image;
import com.lowagie.text.Phrase;
+import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
@@ -242,11 +245,37 @@ 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
+ * @return
+ * @throws PDFDocumentException
+ */
+ private Font getCellTrueTypeFont(String fontString) throws PDFDocumentException {
+ // TODO[tknall-PDF/A]: Remove hardcoded TTF. Impement TTF usage based on configuration.
+ logger_.warn("TrueType Fonts are activated. This is only for testing purposes. Deactivate in final release!");
+ 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 + "DejaVuSansCondensed.ttf";
+ logger_.debug("Instantiating \"" + fontPath + "\".");
+ font = new Font(BaseFont.createFont(fontPath, BaseFont.WINANSI, true), 8);
+ fontMap_.put(fontString, font);
+ }
+ return font;
+ } catch (DocumentException e) {
+ throw new PDFDocumentException(ErrorCode.FONT_NOT_FOUND, e.getMessage());
+ } catch (IOException e) {
+ throw new PDFDocumentException(ErrorCode.FONT_NOT_FOUND, e.getMessage());
+ }
+ }
/**
* This method visualize an abstract table cell into a corresponding pdf table
@@ -284,7 +313,11 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
{
font_string = cell_style.getValueFont();
}
+
+ // TODO[tknall-PDF/A]: Deactivate temporary TTF test.
Font cell_font = getCellFont(font_string);
+// Font cell_font = getCellTrueTypeFont(font_string);
+
Phrase text_phrase = new Phrase(text, cell_font);
pdf_cell = new PdfPCell(text_phrase);
setCellStyle(pdf_cell, cell_style);
diff --git a/src/site/changes.xml b/src/site/changes.xml
index 96307b2..8e1016c 100644
--- a/src/site/changes.xml
+++ b/src/site/changes.xml
@@ -28,6 +28,7 @@
<action dev="tknall" type="add">Preparation for multilingual support for web application.</action>
<action dev="tknall" type="update">Minor updates of configuration.</action>
<action dev="tknall" type="update">Sitemesh updates.</action>
+ <action dev="tknall" type="add">Minor support for TrueType fonts in preparation of PDF/A added.</action>
</release>
<release version="3.0.7-20080923" date="2008-09-23" description="subsequent release">