1 //========================================================================
5 // Copyright 1998 Derek B. Noonburg
7 //========================================================================
13 #include "parseargs.h"
28 GBool printCommands = gFalse;
29 static GBool printHelp = gFalse;
31 static ArgDesc argDesc[] = {
32 {"-h", argFlag, &printHelp, 0,
33 "print usage information"},
34 {"-help", argFlag, &printHelp, 0,
35 "print usage information"},
39 int main(int argc, char *argv[]) {
47 ok = parseArgs(argDesc, &argc, argv);
48 if (!ok || argc != 2 || printHelp) {
49 fprintf(stderr, "pdfinfo version %s\n", xpdfVersion);
50 fprintf(stderr, "%s\n", xpdfCopyright);
51 printUsage("pdfinfo", "<PDF-file>", argDesc);
54 fileName = new GString(argv[1]);
60 initParams(xpdfConfigFile);
64 doc = new PDFDoc(bxpdfopen(fileName), fileName);
69 doc->getDocInfo(&info);
71 if (info.dictLookup("Title", &obj)->isString())
72 printf("Title: %s\n", obj.getString()->getCString());
74 if (info.dictLookup("Subject", &obj)->isString())
75 printf("Subject: %s\n", obj.getString()->getCString());
77 if (info.dictLookup("Keywords", &obj)->isString())
78 printf("Keywords: %s\n", obj.getString()->getCString());
80 if (info.dictLookup("Author", &obj)->isString())
81 printf("Author: %s\n", obj.getString()->getCString());
83 if (info.dictLookup("Creator", &obj)->isString())
84 printf("Creator: %s\n", obj.getString()->getCString());
86 if (info.dictLookup("Producer", &obj)->isString())
87 printf("Producer: %s\n", obj.getString()->getCString());
89 if (info.dictLookup("CreationDate", &obj)->isString()) {
90 s = obj.getString()->getCString();
91 if (s[0] == 'D' && s[1] == ':')
93 printf("CreationDate: %s\n", s);
96 if (info.dictLookup("ModDate", &obj)->isString()) {
97 s = obj.getString()->getCString();
98 if (s[0] == 'D' && s[1] == ':')
100 printf("ModDate: %s\n", s);
107 printf("Pages: %d\n", doc->getNumPages());
109 // print encryption info
110 printf("Encrypted: ");
111 if (doc->isEncrypted()) {
112 printf("yes (print:%s copy:%s)\n",
113 doc->okToPrint() ? "yes" : "no",
114 doc->okToCopy() ? "yes" : "no");
123 // check for memory leaks
124 Object::memCheck(stderr);