-void pdfswf_init(char*filename, char*userPassword)
-{
- 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;
- }
- 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();
- if (doc->isEncrypted()) {
- if(!doc->okToCopy()) {
- printf("PDF disallows copying. Bailing out.\n");
- exit(1); //bail out
- }
- if(!doc->okToChange() || !doc->okToAddNotes())
- swfoutput_setprotected();
- }
-
- output = new SWFOutputDev();
- output->startDoc(doc->getXRef());
-}
-