//
// pdfinfo.cc
//
-// Copyright 1998-2002 Glyph & Cog, LLC
+// Copyright 1998-2003 Glyph & Cog, LLC
//
//========================================================================
GString *ownerPW, *userPW;
UnicodeMap *uMap;
Object info;
- double w, h;
+ double w, h, wISO, hISO;
FILE *f;
GString *metadata;
GBool ok;
+ int exitCode;
+ int i;
+
+ exitCode = 99;
// parse args
ok = parseArgs(argDesc, &argc, argv);
if (!printVersion) {
printUsage("pdfinfo", "<PDF-file>", argDesc);
}
- exit(1);
+ goto err0;
}
fileName = new GString(argv[1]);
delete ownerPW;
}
if (!doc->isOk()) {
+ exitCode = 1;
goto err2;
}
if ((fabs(w - 612) < 0.1 && fabs(h - 792) < 0.1) ||
(fabs(w - 792) < 0.1 && fabs(h - 612) < 0.1)) {
printf(" (letter)");
- } else if ((fabs(w - 595) < 0.1 && fabs(h - 842) < 0.1) ||
- (fabs(w - 842) < 0.1 && fabs(h - 595) < 0.1)) {
- printf(" (A4)");
+ } else {
+ hISO = sqrt(sqrt(2)) * 7200 / 2.54;
+ wISO = hISO / sqrt(2);
+ for (i = 0; i <= 6; ++i) {
+ if ((fabs(w - wISO) < 1 && fabs(h - hISO) < 1) ||
+ (fabs(w - hISO) < 1 && fabs(h - wISO) < 1)) {
+ printf(" (A%d)", i);
+ break;
+ }
+ hISO = wISO;
+ wISO /= sqrt(2);
+ }
}
printf("\n");
}
f = fopen(fileName->getCString(), "rb");
#endif
if (f) {
-#if HAVE_FSEEK64
+#if HAVE_FSEEKO
+ fseeko(f, 0, SEEK_END);
+ printf("File size: %u bytes\n", (Guint)ftello(f));
+#elif HAVE_FSEEK64
fseek64(f, 0, SEEK_END);
printf("File size: %u bytes\n", (Guint)ftell64(f));
#else
delete metadata;
}
+ exitCode = 0;
+
// clean up
err2:
uMap->decRefCnt();
delete doc;
err1:
delete globalParams;
+ err0:
// check for memory leaks
Object::memCheck(stderr);
gMemReport(stderr);
- return 0;
+ return exitCode;
}
static void printInfoString(Dict *infoDict, char *key, char *text,
tmStruct.tm_wday = -1;
tmStruct.tm_yday = -1;
tmStruct.tm_isdst = -1;
- mktime(&tmStruct); // compute the tm_wday and tm_yday fields
- if (strftime(buf, sizeof(buf), "%c", &tmStruct)) {
+ // compute the tm_wday and tm_yday fields
+ if (mktime(&tmStruct) != (time_t)-1 &&
+ strftime(buf, sizeof(buf), "%c", &tmStruct)) {
fputs(buf, stdout);
} else {
fputs(s, stdout);