+ pdf_doc_t*pdf_doc = (pdf_doc_t*)malloc(sizeof(pdf_doc_t));
+ memset(pdf_doc, 0, sizeof(pdf_doc_t));
+ pdf_doc_internal_t*i= (pdf_doc_internal_t*)malloc(sizeof(pdf_doc_internal_t));
+ memset(i, 0, sizeof(pdf_doc_internal_t));
+ pdf_doc->internal = i;
+
+ GString *fileName = new GString(filename);
+ GString *userPW;
+ Object info;
+
+ // read config file
+ globalParams = new GlobalParams("");
+
+ // open PDF file
+ if (userPassword && userPassword[0]) {
+ userPW = new GString(userPassword);
+ } else {
+ userPW = NULL;
+ }
+ i->doc = new PDFDoc(fileName, userPW);
+ if (userPW) {
+ delete userPW;
+ }
+ if (!i->doc->isOk()) {
+ return 0;
+ }
+
+ // print doc info
+ i->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", i->doc->getNumPages());
+ printf("Linearized: %s\n", i->doc->isLinearized() ? "yes" : "no");
+ printf("Encrypted: ");
+ if (i->doc->isEncrypted()) {
+ printf("yes (print:%s copy:%s change:%s addNotes:%s)\n",
+ i->doc->okToPrint() ? "yes" : "no",
+ i->doc->okToCopy() ? "yes" : "no",
+ i->doc->okToChange() ? "yes" : "no",
+ i->doc->okToAddNotes() ? "yes" : "no");
+ } else {
+ printf("no\n");
+ }
+ }
+ info.free();
+
+ pdf_doc->num_pages = i->doc->getNumPages();
+ i->protect = 0;
+ if (i->doc->isEncrypted()) {
+ if(!i->doc->okToCopy()) {
+ printf("PDF disallows copying. Terminating.\n");
+ exit(1); //bail out
+ }
+ if(!i->doc->okToChange() || !i->doc->okToAddNotes())
+ i->protect = 1;
+ }
+
+ return pdf_doc;
+}
+
+void pdfswf_preparepage(int page)
+{
+ /*FIXME*/
+ if(!pages) {