From 0f58fa4b202c8dc56909d1403697fbf53b976307 Mon Sep 17 00:00:00 2001 From: pdanner Date: Mon, 8 Nov 2010 15:34:11 +0000 Subject: improved alt text git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@603 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/pdf/StructContentHelper.java | 36 +++++----------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java index 19a32ac..55e77e0 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java @@ -3,8 +3,6 @@ package at.knowcenter.wag.egov.egiz.pdf; import org.apache.log4j.Logger; import at.gv.egiz.pdfas.exceptions.ErrorCode; -import at.gv.egiz.pdfas.framework.signator.SignatorInformation; -import at.knowcenter.wag.egov.egiz.exceptions.InvalidIDException; import at.knowcenter.wag.egov.egiz.exceptions.PresentableException; import at.knowcenter.wag.egov.egiz.sig.SignatureObject; @@ -30,9 +28,11 @@ import com.lowagie.text.pdf.PdfString; * */ public class StructContentHelper { + private static final String ALT_TEXT_DEFAULT = "PDF-AS Signatur"; + private static Logger logger = Logger.getLogger(StructContentHelper.class); - private final static String ALT_TEXT_KEY = "sigBlockAltText"; + private final static String ALT_TEXT_CONF_KEY = "sigBlockAltText"; private int nextMcid = 0; private boolean isTagged = false; @@ -56,7 +56,7 @@ public class StructContentHelper { * Create and write structured content for signature block * @throws PresentableException */ - void buildMainStructData(SignatureObject so, SignatorInformation si) throws PresentableException { + void buildMainStructData(SignatureObject so) throws PresentableException { try { @@ -143,7 +143,7 @@ public class StructContentHelper { newStruct.put(PdfName.TYPE, new PdfName("StructElem")); newStruct.put(PdfName.PG, page.getIndRef()); - newStruct.put(PdfName.ALT, new PdfString(createAltText(so, si))); + newStruct.put(PdfName.ALT, new PdfString(getAltText(so.getSignatureTypeDefinition().getType()))); newStruct.put(PdfName.K, new PdfNumber(nextMcid)); @@ -278,32 +278,10 @@ public class StructContentHelper { private PdfDictionary getStructTreeRoot() { return stamper.getReader().getCatalog().getAsDict(PdfName.STRUCTTREEROOT); - } - - private String createAltText(SignatureObject so, SignatorInformation si) { - String profileId = so.getSignatureTypeDefinition().getType(); - String res = getAltText(profileId); // ask config for alt text - if (res == null) { - // make default alt text - StringBuilder sb = new StringBuilder("PDF-AS Signatur"); - - try { - if (so != null && so.getKZ() != null) { - sb.append(". ").append(so.getKZ().toString()); - } else if (si != null) { - sb.append(". ").append(si.getSignSignatureObject().kz); - } - } catch (InvalidIDException e) { - logger.debug("error reading signature method for alt text string"); - } - sb.append(". ").append(profileId); - res = sb.toString(); - } - return res; - } + } public static String getAltText(String sigProfile) { - return AdobeSignatureHelper.getDefaultableConfigProperty(sigProfile, ALT_TEXT_KEY, null); + return AdobeSignatureHelper.getDefaultableConfigProperty(sigProfile, ALT_TEXT_CONF_KEY, ALT_TEXT_DEFAULT); } -- cgit v1.2.3