aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-12-22 17:20:28 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-12-22 17:20:28 +0000
commit1dc37425d3bfc0beb41945e36fa06710adda3d42 (patch)
tree78ef5c061c15b95f47f9bc80bb183bc88f6e0302
parent3d88697da5a47139625700e591bef9baada4258a (diff)
downloadpdf-as-3-1dc37425d3bfc0beb41945e36fa06710adda3d42.tar.gz
pdf-as-3-1dc37425d3bfc0beb41945e36fa06710adda3d42.tar.bz2
pdf-as-3-1dc37425d3bfc0beb41945e36fa06710adda3d42.zip
Demos updated
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@522 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
-rw-r--r--src/main/java/demo/ExtractNonTextualObjectsDemo.java4
-rw-r--r--src/main/java/demo/SignatureCreationDemo.java2
-rw-r--r--src/main/java/demo/SignatureVerificationDemo.java32
3 files changed, 33 insertions, 5 deletions
diff --git a/src/main/java/demo/ExtractNonTextualObjectsDemo.java b/src/main/java/demo/ExtractNonTextualObjectsDemo.java
index 60031f7..6b0f3eb 100644
--- a/src/main/java/demo/ExtractNonTextualObjectsDemo.java
+++ b/src/main/java/demo/ExtractNonTextualObjectsDemo.java
@@ -31,7 +31,7 @@ public class ExtractNonTextualObjectsDemo {
System.err.println("Please provide path of file to be analyzed.");
System.exit(1);
}
-
+
File testFile = new File(args[0]);
try {
@@ -41,7 +41,7 @@ public class ExtractNonTextualObjectsDemo {
List nonTextualObjects = PdfAS.extractNonTextualObjects(new PdfDataSourceAdapter(dataSource));
if (nonTextualObjects != null && !nonTextualObjects.isEmpty()) {
- System.out.println("Non-textual objects found.");
+ System.out.println(nonTextualObjects.size() + " non-textual object(s) found.");
Iterator noit = nonTextualObjects.iterator();
while (noit.hasNext()) {
NonTextObjectInfo info = (NonTextObjectInfo) noit.next();
diff --git a/src/main/java/demo/SignatureCreationDemo.java b/src/main/java/demo/SignatureCreationDemo.java
index 465a0bf..1f6205d 100644
--- a/src/main/java/demo/SignatureCreationDemo.java
+++ b/src/main/java/demo/SignatureCreationDemo.java
@@ -78,7 +78,7 @@ public class SignatureCreationDemo {
// check if non textual elements have been detected
if (signResult.hasNonTextualObjects()) {
- System.out.println("\nWARNING: Non textual objects detected.");
+ System.out.println("\nWARNING: " + signResult.getNonTextualObjects().size() + " non textual object(s) detected.");
Iterator noit = signResult.getNonTextualObjects().iterator();
while (noit.hasNext()) {
NonTextObjectInfo info = (NonTextObjectInfo) noit.next();
diff --git a/src/main/java/demo/SignatureVerificationDemo.java b/src/main/java/demo/SignatureVerificationDemo.java
index 86d1bb8..950472e 100644
--- a/src/main/java/demo/SignatureVerificationDemo.java
+++ b/src/main/java/demo/SignatureVerificationDemo.java
@@ -12,6 +12,7 @@ import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters;
import at.gv.egiz.pdfas.api.analyze.AnalyzeResult;
import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
import at.gv.egiz.pdfas.api.commons.Constants;
+import at.gv.egiz.pdfas.api.commons.SignatureInformation;
import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
import at.gv.egiz.pdfas.api.io.DataSource;
import at.gv.egiz.pdfas.api.verify.VerifyAfterAnalysisParameters;
@@ -71,6 +72,30 @@ public class SignatureVerificationDemo {
AnalyzeResult analyzeResult = pdfasAPI.analyze(analyzeParameters);
System.out.println("Successfully analyzed.");
+ // information on non-textual objects can be used after analysis step and/or after verification
+ List signatures = analyzeResult.getSignatures();
+ if (signatures != null && !signatures.isEmpty()) {
+ int counter = 0;
+ Iterator sigIterator = signatures.iterator();
+ while (sigIterator.hasNext()) {
+ counter++;
+ SignatureInformation sigInfo = (SignatureInformation) sigIterator.next();
+ System.out.println("\n------------------------ SIGNATURE #" + counter + " ------------------------");
+ if (sigInfo.hasNonTextualObjects()) {
+ System.out.println("\nWARNING: " + sigInfo.getNonTextualObjects().size() + " non textual object(s) detected for this signature.");
+ Iterator noit = sigInfo.getNonTextualObjects().iterator();
+ while (noit.hasNext()) {
+ NonTextObjectInfo info = (NonTextObjectInfo) noit.next();
+ System.out.println(" -> " + info.toString());
+ }
+ System.out.println();
+
+ } else {
+ System.out.println("\nNo non-textual objects detected for this signature.");
+ }
+ }
+ }
+
// setup verification
VerifyAfterAnalysisParameters vaap = new VerifyAfterAnalysisParameters();
vaap.setAnalyzeResult(analyzeResult);
@@ -82,13 +107,16 @@ public class SignatureVerificationDemo {
System.out.println("Verifying...");
VerifyResults verifyResults = pdfasAPI.verify(vaap);
List verifyResultList = verifyResults.getResults();
- System.out.println("Verification complete.");
+ System.out.println("Verification complete.\n");
// iterate over results
PrintWriter out = new PrintWriter(System.out);
Iterator it = verifyResultList.iterator();
+ int counter = 0;
while (it.hasNext()) {
+ counter++;
VerifyResult result = (VerifyResult) it.next();
+ out.println("\n------------------------ SIGNATURE #" + counter + " ------------------------\n");
Main.formatVerifyResult(result, out);
// check if there are timestamps
@@ -98,7 +126,7 @@ public class SignatureVerificationDemo {
// check if non textual elements have been detected for this signature
if (result.hasNonTextualObjects()) {
- out.println("\nWARNING: Non textual objects detected for this signature");
+ out.println("\nWARNING: " + result.getNonTextualObjects().size() + " non textual object(s) detected for this signature");
Iterator noit = result.getNonTextualObjects().iterator();
while (noit.hasNext()) {
NonTextObjectInfo info = (NonTextObjectInfo) noit.next();