From f3476576c50efd922593c82656efda7aec5ae97f Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 27 Nov 2013 10:05:17 +0100 Subject: MOA integration sign/verification (not finished yet ...) Lots of PDF-AS Web implementation --- .../stmp-itext/src/main/java/META-INF/MANIFEST.MF | 3 ++ .../at/gv/egiz/pdfas/stmp/itext/ITextStamper.java | 51 +++++++++++----------- 2 files changed, 29 insertions(+), 25 deletions(-) create mode 100644 stamper/stmp-itext/src/main/java/META-INF/MANIFEST.MF (limited to 'stamper/stmp-itext/src/main') diff --git a/stamper/stmp-itext/src/main/java/META-INF/MANIFEST.MF b/stamper/stmp-itext/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 00000000..5e949512 --- /dev/null +++ b/stamper/stmp-itext/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/stamper/stmp-itext/src/main/java/at/gv/egiz/pdfas/stmp/itext/ITextStamper.java b/stamper/stmp-itext/src/main/java/at/gv/egiz/pdfas/stmp/itext/ITextStamper.java index 5c0fb7df..ff68dcd8 100644 --- a/stamper/stmp-itext/src/main/java/at/gv/egiz/pdfas/stmp/itext/ITextStamper.java +++ b/stamper/stmp-itext/src/main/java/at/gv/egiz/pdfas/stmp/itext/ITextStamper.java @@ -111,7 +111,9 @@ public class ITextStamper implements IPDFStamper { /** * Map the font definitions to IText's font statements */ - private static HashMap fontMap_ = new HashMap(); + private static HashMap fontStyleMap_ = new HashMap(); + + private static HashMap fontMap_ = new HashMap(); static { initStyleMaps(); @@ -129,16 +131,17 @@ public class ITextStamper implements IPDFStamper { alignMap_.put(Style.LEFT, new Integer(Element.ALIGN_LEFT)); alignMap_.put(Style.CENTER, new Integer(Element.ALIGN_CENTER)); alignMap_.put(Style.RIGHT, new Integer(Element.ALIGN_RIGHT)); - - fontMap_.put(Style.HELVETICA, new Integer(Font.HELVETICA)); - fontMap_.put(Style.TIMES_ROMAN, new Integer(Font.TIMES_ROMAN)); - fontMap_.put(Style.COURIER, new Integer(Font.COURIER)); - fontMap_.put(Style.NORMAL, new Integer(Font.NORMAL)); - fontMap_.put(Style.BOLD, new Integer(Font.BOLD)); - fontMap_.put(Style.ITALIC, new Integer(Font.ITALIC)); - fontMap_.put(Style.BOLDITALIC, new Integer(Font.BOLDITALIC)); - fontMap_.put(Style.UNDERLINE, new Integer(Font.UNDERLINE)); - fontMap_.put(Style.STRIKETHRU, new Integer(Font.STRIKETHRU)); + + //BaseFont.createFont() + fontStyleMap_.put(Style.HELVETICA, new Integer(Font.HELVETICA)); + fontStyleMap_.put(Style.TIMES_ROMAN, new Integer(Font.TIMES_ROMAN)); + fontStyleMap_.put(Style.COURIER, new Integer(Font.COURIER)); + fontStyleMap_.put(Style.NORMAL, new Integer(Font.NORMAL)); + fontStyleMap_.put(Style.BOLD, new Integer(Font.BOLD)); + fontStyleMap_.put(Style.ITALIC, new Integer(Font.ITALIC)); + fontStyleMap_.put(Style.BOLDITALIC, new Integer(Font.BOLDITALIC)); + fontStyleMap_.put(Style.UNDERLINE, new Integer(Font.UNDERLINE)); + fontStyleMap_.put(Style.STRIKETHRU, new Integer(Font.STRIKETHRU)); } /** @@ -225,26 +228,24 @@ public class ITextStamper implements IPDFStamper { } logger.debug("TrueType Font detected:"+fontName +" ("+fontSize+")"); - //try { - - Font font = new Font(fontMap_.get(fontString)); - //Font font = (Font) fontMap_.get(fontString); + try { + Font font = (Font) fontMap_.get(fontString); // TODO: implement FONT resources via settings path! - /*if (font == null) { + if (font == null) { logger.debug("Font \"" + fontString + "\" not in cache. Instantiating font."); - String fontPath = SettingsReader.RESOURCES_PATH + "fonts" + File.separator + fontName; + String fontPath = this.settings.getWorkingDirectory() + File.separator + "fonts" + File.separator + fontName; logger.debug("Instantiating \"" + fontPath + "\"."); font = new Font(BaseFont.createFont(fontPath, BaseFont.WINANSI, true), fontSize); fontMap_.put(fontString, font); - } */ + } return font; - // } catch (DocumentException e) { - // throw new PdfAsException(e.getMessage()); - //} catch (IOException e) { - // throw new PdfAsException(e.getMessage()); - //} + } catch (DocumentException e) { + throw new PdfAsException(e.getMessage()); + } catch (IOException e) { + throw new PdfAsException(e.getMessage()); + } } @@ -272,12 +273,12 @@ public class ITextStamper implements IPDFStamper { { return font; } - Object font_face = fontMap_.get(font_arr[0]); + Object font_face = fontStyleMap_.get(font_arr[0]); if (font_face == null) { return font; } - Object font_weight = fontMap_.get(font_arr[2]); + Object font_weight = fontStyleMap_.get(font_arr[2]); if (font_weight == null) { return font; -- cgit v1.2.3