+ doc = new PDFDoc(fileName, userPW);
+ if (userPW) {
+ delete userPW;
+ }
+ if (!doc->isOk()) {
+ exit(1);
+ }
+
+ // print doc info
+ doc->getDocInfo(&info);
+ if (info.isDict() &&
+ (screenloglevel>=LOGLEVEL_NOTICE)) {
+ printInfoString(info.getDict(), "Title", "Title: %s\n");
+ printInfoString(info.getDict(), "Subject", "Subject: %s\n");
+ printInfoString(info.getDict(), "Keywords", "Keywords: %s\n");
+ printInfoString(info.getDict(), "Author", "Author: %s\n");
+ printInfoString(info.getDict(), "Creator", "Creator: %s\n");
+ printInfoString(info.getDict(), "Producer", "Producer: %s\n");
+ printInfoDate(info.getDict(), "CreationDate", "CreationDate: %s\n");
+ printInfoDate(info.getDict(), "ModDate", "ModDate: %s\n");
+ printf("Pages: %d\n", doc->getNumPages());
+ printf("Linearized: %s\n", doc->isLinearized() ? "yes" : "no");
+ printf("Encrypted: ");
+ if (doc->isEncrypted()) {
+ printf("yes (print:%s copy:%s change:%s addNotes:%s)\n",
+ doc->okToPrint() ? "yes" : "no",
+ doc->okToCopy() ? "yes" : "no",
+ doc->okToChange() ? "yes" : "no",
+ doc->okToAddNotes() ? "yes" : "no");
+ } else {
+ printf("no\n");
+ }
+ }
+ info.free();
+
+ numpages = doc->getNumPages();
+ int protect = 0;
+ if (doc->isEncrypted()) {
+ if(!doc->okToCopy()) {
+ printf("PDF disallows copying. Terminating.\n");
+ exit(1); //bail out
+ }
+ if(!doc->okToChange() || !doc->okToAddNotes())
+ protect = 1;
+ }
+
+ if(protect)
+ swfoutput_setparameter("protect", "1");