diff options
author | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-12-02 18:10:49 +0000 |
---|---|---|
committer | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-12-02 18:10:49 +0000 |
commit | 840d6a4b71e5c8c0273be231a85306be26356933 (patch) | |
tree | d8f884e5b574f3b8b3e6bb4493a1b5527304346e /src/main/java/demo/ExtractNonTextualObjectsDemo.java | |
parent | 1fba63b7c5a897881096fe1f7f3ec19872ef5fdb (diff) | |
download | pdf-as-3-840d6a4b71e5c8c0273be231a85306be26356933.tar.gz pdf-as-3-840d6a4b71e5c8c0273be231a85306be26356933.tar.bz2 pdf-as-3-840d6a4b71e5c8c0273be231a85306be26356933.zip |
Two demos added, showing extraction of non-textual objects during signature and verification
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@484 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/demo/ExtractNonTextualObjectsDemo.java')
-rw-r--r-- | src/main/java/demo/ExtractNonTextualObjectsDemo.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/demo/ExtractNonTextualObjectsDemo.java b/src/main/java/demo/ExtractNonTextualObjectsDemo.java new file mode 100644 index 0000000..d7c651f --- /dev/null +++ b/src/main/java/demo/ExtractNonTextualObjectsDemo.java @@ -0,0 +1,60 @@ +package demo;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
+import at.gv.egiz.pdfas.api.io.DataSource;
+import at.gv.egiz.pdfas.impl.api.commons.PdfDataSourceAdapter;
+import at.gv.egiz.pdfas.io.FileBasedDataSource;
+import at.knowcenter.wag.egov.egiz.PdfAS;
+
+public class ExtractNonTextualObjectsDemo {
+
+ /**
+ * Disable instantiation.
+ */
+ private ExtractNonTextualObjectsDemo() {
+ }
+
+ /**
+ * Starts a demo that extracts non-textual elements from a document.
+ *
+ * @param args
+ * The parameter(s).
+ */
+ public static void main(String[] args) {
+
+ if (args == null || args.length == 0) {
+ System.err.println("Please provide path of file to be signed.");
+ System.exit(1);
+ }
+
+ File testFile = new File(args[0]);
+
+ try {
+
+ // set source
+ DataSource dataSource = new FileBasedDataSource(testFile, "application/pdf");
+
+ List nonTextualObjects = PdfAS.extractNonTextualObjects(new PdfDataSourceAdapter(dataSource));
+ if (nonTextualObjects != null && !nonTextualObjects.isEmpty()) {
+ System.out.println("Non-textual objects found.");
+ Iterator noit = nonTextualObjects.iterator();
+ while (noit.hasNext()) {
+ NonTextObjectInfo info = (NonTextObjectInfo) noit.next();
+ System.out.println(" -> " + info.toString());
+ }
+ } else {
+ System.out.println("No non-textual objects found.");
+ }
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
|