aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java')
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java47
1 files changed, 34 insertions, 13 deletions
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.");
+ }
+ }
+ }
+
+