From db52e4d66d60184d53a27ba4d6772461daacc03d Mon Sep 17 00:00:00 2001 From: tknall Date: Fri, 22 Mar 2013 08:57:51 +0000 Subject: Maintenance update (bugfixes, new features, cleanup...) Refer to /dok/RELEASE_NOTES-3.3.txt for further information. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/pdf-as/trunk@931 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/pdf/StructContentHelper.java | 47 ++++++++++++++++------ 1 file changed, 34 insertions(+), 13 deletions(-) (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java') diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java index a9c1c54..deb5fed 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java @@ -173,9 +173,8 @@ public class StructContentHelper implements StructContentWriter { } } catch (Exception ex) { - logger.error("error", ex); - throw new PresentableException(ErrorCode.CANNOT_WRITE_PDF, - "error writing structured signature content", ex); + logger.warn("Unable to process structured document data. Going to write untagged signature block.", ex); + isTagged = false; } } @@ -471,16 +470,38 @@ public class StructContentHelper implements StructContentWriter { } } - private void checkTagging() { - PdfDictionary markDict = stamper.getReader().getCatalog().getAsDict(PdfName.MARKINFO); - if (markDict != null) { - isTagged = markDict.getAsBoolean(PdfName.MARKED).booleanValue(); - } - if (!isTagged) { - logger.debug("input document is not tagged. no structure/wai information is written"); - } - logger.debug("Input is tagged. Writing structure/WAI data."); - } + private void checkTagging() { + PdfDictionary markDict = stamper.getReader().getCatalog().getAsDict(PdfName.MARKINFO); + if (markDict != null) { + isTagged = markDict.getAsBoolean(PdfName.MARKED).booleanValue(); + } + if (!isTagged) { + logger.debug("Input document is not tagged. No structure data will be attached to signature block."); + } else { + logger.trace("Document claims to be tagged. Checking availability of structured tree root."); + PdfDictionary structTreeRoot; + if ((structTreeRoot = getStructTreeRoot()) == null) { + // document claimed to be tagged but document does not contain structural information + isTagged = false; + logger.debug("Document claims to be tagged structured tree root was not found."); + } else if (getParentTreeNums() == null) { + // document claimed to be tagged but document does not contain structural information + isTagged = false; + logger.debug("Document claims to be tagged but required information is missing."); + } else if (structTreeRoot.getDirectObject(PdfName.K) == null) { + // structured content + isTagged = false; + logger.debug("Document claims to be tagged but required information is missing."); + } else { + logger.debug("Input is tagged and required structure data seems to be available. Going to write structured signature block."); + } + if (!isTagged) { + logger.info("Unable to process structured document data. Going to write untagged signature block."); + } + } + } + + -- cgit v1.2.3