Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pdf/xpdf/pdfinfo.cc
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1999-04-17 02:59:58 (GMT)
committer Arturo Espinosa <unammx@src.gnome.org>1999-04-17 02:59:58 (GMT)
commitd9f9a6449f377b4c933b75d57541b19c6d088994 (patch)
tree04f7f0c54447ef792fbf83bc5039174f4681b3bb /pdf/xpdf/pdfinfo.cc
Initial revision
Diffstat (limited to 'pdf/xpdf/pdfinfo.cc')
-rw-r--r--pdf/xpdf/pdfinfo.cc121
1 files changed, 121 insertions, 0 deletions
diff --git a/pdf/xpdf/pdfinfo.cc b/pdf/xpdf/pdfinfo.cc
new file mode 100644
index 0000000..fae8a18
--- /dev/null
+++ b/pdf/xpdf/pdfinfo.cc
@@ -0,0 +1,121 @@
+//========================================================================
+//
+// pdfinfo.cc
+//
+// Copyright 1998 Derek B. Noonburg
+//
+//========================================================================
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#include "parseargs.h"
+#include "GString.h"
+#include "gmem.h"
+#include "Object.h"
+#include "Stream.h"
+#include "Array.h"
+#include "Dict.h"
+#include "XRef.h"
+#include "Catalog.h"
+#include "Page.h"
+#include "PDFDoc.h"
+#include "Params.h"
+#include "Error.h"
+#include "config.h"
+
+GBool printCommands = gFalse;
+static GBool printHelp = gFalse;
+
+static ArgDesc argDesc[] = {
+ {"-h", argFlag, &printHelp, 0,
+ "print usage information"},
+ {"-help", argFlag, &printHelp, 0,
+ "print usage information"},
+ {NULL}
+};
+
+int main(int argc, char *argv[]) {
+ PDFDoc *doc;
+ GString *fileName;
+ Object info, obj;
+ char *s;
+ GBool ok;
+
+ // parse args
+ ok = parseArgs(argDesc, &argc, argv);
+ if (!ok || argc != 2 || printHelp) {
+ fprintf(stderr, "pdfinfo version %s\n", xpdfVersion);
+ fprintf(stderr, "%s\n", xpdfCopyright);
+ printUsage("pdfinfo", "<PDF-file>", argDesc);
+ exit(1);
+ }
+ fileName = new GString(argv[1]);
+
+ // init error file
+ errorInit();
+
+ // read config file
+ initParams(xpdfConfigFile);
+
+ // open PDF file
+ xref = NULL;
+ doc = new PDFDoc(fileName);
+ if (!doc->isOk())
+ exit(1);
+
+ // print doc info
+ doc->getDocInfo(&info);
+ if (info.isDict()) {
+ if (info.dictLookup("Title", &obj)->isString())
+ printf("Title: %s\n", obj.getString()->getCString());
+ obj.free();
+ if (info.dictLookup("Subject", &obj)->isString())
+ printf("Subject: %s\n", obj.getString()->getCString());
+ obj.free();
+ if (info.dictLookup("Keywords", &obj)->isString())
+ printf("Keywords: %s\n", obj.getString()->getCString());
+ obj.free();
+ if (info.dictLookup("Author", &obj)->isString())
+ printf("Author: %s\n", obj.getString()->getCString());
+ obj.free();
+ if (info.dictLookup("Creator", &obj)->isString())
+ printf("Creator: %s\n", obj.getString()->getCString());
+ obj.free();
+ if (info.dictLookup("Producer", &obj)->isString())
+ printf("Producer: %s\n", obj.getString()->getCString());
+ obj.free();
+ if (info.dictLookup("CreationDate", &obj)->isString()) {
+ s = obj.getString()->getCString();
+ if (s[0] == 'D' && s[1] == ':')
+ s += 2;
+ printf("CreationDate: %s\n", s);
+ }
+ obj.free();
+ if (info.dictLookup("ModDate", &obj)->isString()) {
+ s = obj.getString()->getCString();
+ if (s[0] == 'D' && s[1] == ':')
+ s += 2;
+ printf("ModDate: %s\n", s);
+ }
+ obj.free();
+ }
+ info.free();
+
+ // print page count
+ printf("Pages: %d\n", doc->getNumPages());
+
+ // print encrypted flag
+ printf("Encrypted: %s\n", doc->isEncrypted() ? "yes" : "no");
+
+ // clean up
+ delete doc;
+ freeParams();
+
+ // check for memory leaks
+ Object::memCheck(errFile);
+ gMemReport(errFile);
+
+ return 0;
+}