diff options
author | ferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2010-01-05 14:43:10 +0000 |
---|---|---|
committer | ferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2010-01-05 14:43:10 +0000 |
commit | f2ab6263e22b06f9aee4caeb2f5ebadf8dc5076c (patch) | |
tree | f0b8e421305e4df2fe492dbf322addfc25964bc3 /src/main | |
parent | 1eca0bcc65e92cef6cb142be30a0273ac18481a4 (diff) | |
download | pdf-as-3-f2ab6263e22b06f9aee4caeb2f5ebadf8dc5076c.tar.gz pdf-as-3-f2ab6263e22b06f9aee4caeb2f5ebadf8dc5076c.tar.bz2 pdf-as-3-f2ab6263e22b06f9aee4caeb2f5ebadf8dc5076c.zip |
narrow sig skipping to Adobe.PDF-AS filter
added debugging
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@535 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java index ecee0dd..cd6d449 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/ObjectExtractor.java @@ -7,6 +7,8 @@ import java.util.List; import java.util.Map;
import org.apache.log4j.Logger;
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDResources;
@@ -43,10 +45,16 @@ public class ObjectExtractor { try {
PDAnnotation anno = (PDAnnotation) it.next();
log.debug("found annotation: " +anno);
+ if (log.isTraceEnabled()) {
+ log.trace("annotation def: " + dictToString(anno.getDictionary()));
+ }
String ft = anno.getDictionary().getNameAsString("FT");
if (ft != null && ft.equals("Sig")) { // skip signature widgets
- log.debug("found signature widged, skip further extraction");
- break;
+ COSDictionary sigDict = (COSDictionary) anno.getDictionary().getDictionaryObject("V");
+ if (sigDict != null && AdobeSignatureHelper.ADOBE_SIG_FILTER.equals(sigDict.getNameAsString("Filter"))) {
+ log.debug("found PDF-AS signature widged, skip further extraction");
+ continue;
+ }
}
NonTextObjectInfo objInfo = new NonTextObjectInfo();
objInfo.setName(anno.getDictionary().getString( "NM" ));
@@ -68,6 +76,27 @@ public class ObjectExtractor { }
}
}
+
+ /**
+ * Create string representation from COSDictionary
+ * @param dict
+ * @return
+ */
+ public static String dictToString(COSDictionary dict)
+ {
+ try {
+ String retVal = "COSDictionary{";
+ for (int i = 0; i<dict.size(); i++)
+ {
+ COSName key = (COSName)dict.keyList().get(i);
+ retVal = retVal + "(" + key + ":" + dict.getItem(key) + ") ";
+ }
+ retVal = retVal + "}";
+ return retVal;
+ } catch (Exception e) {
+ return "no detail available";
+ }
+ }
/**
* Find resources (images) in pdf documents
|