+int jpeg_dpi = 0;
+int ppm_dpi = 0;
+
+void storeDeviceParameter(char*name, char*value)
+{
+ parameter_t*p = new parameter_t();
+ p->name = strdup(name);
+ p->value = strdup(value);
+ p->next = 0;
+ if(device_config_next) {
+ device_config_next->next = p;
+ device_config_next = p;
+ } else {
+ device_config = p;
+ device_config_next = p;
+ }
+}
+
+void pdfswf_setparameter(char*name, char*value)
+{
+ msg("<verbose> setting parameter %s to \"%s\"", name, value);
+ if(!strcmp(name, "caplinewidth")) {
+ caplinewidth = atof(value);
+ } else if(!strcmp(name, "zoom")) {
+ char buf[80];
+ zoom = atof(value);
+ sprintf(buf, "%f", (double)jpeg_dpi/(double)zoom);
+ storeDeviceParameter("jpegsubpixels", buf);
+ sprintf(buf, "%f", (double)ppm_dpi/(double)zoom);
+ storeDeviceParameter("ppmsubpixels", buf);
+ } else if(!strcmp(name, "jpegdpi")) {
+ char buf[80];
+ jpeg_dpi = atoi(value);
+ sprintf(buf, "%f", (double)jpeg_dpi/(double)zoom);
+ storeDeviceParameter("jpegsubpixels", buf);
+ } else if(!strcmp(name, "ppmdpi")) {
+ char buf[80];
+ ppm_dpi = atoi(value);
+ sprintf(buf, "%f", (double)ppm_dpi/(double)zoom);
+ storeDeviceParameter("ppmsubpixels", buf);
+ } else if(!strcmp(name, "forceType0Fonts")) {
+ forceType0Fonts = atoi(value);
+ } else if(!strncmp(name, "fontdir", strlen("fontdir"))) {
+ pdfswf_addfontdir(value);
+ } else if(!strncmp(name, "languagedir", strlen("languagedir"))) {
+ pdfswf_addlanguagedir(value);
+ } else if(!strcmp(name, "fontconfig")) {
+ config_use_fontconfig = atoi(value);
+ } else {
+ storeDeviceParameter(name,value);
+ }
+}
+void pdfswf_addfont(char*filename)
+{
+ fontfile_t f;
+ memset(&f, 0, sizeof(fontfile_t));
+ f.filename = filename;
+ if(fontnum < sizeof(fonts)/sizeof(fonts[0])) {
+ fonts[fontnum++] = f;
+ } else {
+ msg("<error> Too many external fonts. Not adding font file \"%s\".", filename);
+ }
+}
+
+static char* dirseparator()
+{
+#ifdef WIN32
+ return "\\";
+#else
+ return "/";
+#endif
+}
+
+void pdfswf_addlanguagedir(char*dir)
+{
+ if(!globalParams)
+ globalParams = new GlobalParams("");
+
+ msg("<notice> Adding %s to language pack directories", dir);
+
+ int l;
+ FILE*fi = 0;
+ char* config_file = (char*)malloc(strlen(dir) + 1 + sizeof("add-to-xpdfrc") + 1);
+ strcpy(config_file, dir);
+ strcat(config_file, dirseparator());
+ strcat(config_file, "add-to-xpdfrc");
+
+ fi = fopen(config_file, "rb");
+ if(!fi) {
+ msg("<error> Could not open %s", config_file);
+ return;
+ }
+ globalParams->parseFile(new GString(config_file), fi);
+ fclose(fi);
+}
+
+void pdfswf_addfontdir(char*dirname)
+{
+#ifdef HAVE_DIRENT_H
+ msg("<notice> Adding %s to font directories", dirname);
+ lastfontdir = strdup(dirname);
+ DIR*dir = opendir(dirname);
+ if(!dir) {
+ msg("<warning> Couldn't open directory %s\n", dirname);
+ return;
+ }
+ struct dirent*ent;
+ while(1) {
+ ent = readdir (dir);
+ if (!ent)
+ break;
+ int l;
+ char*name = ent->d_name;
+ char type = 0;
+ if(!name) continue;
+ l=strlen(name);
+ if(l<4)
+ continue;
+ if(!strncasecmp(&name[l-4], ".pfa", 4))
+ type=1;
+ if(!strncasecmp(&name[l-4], ".pfb", 4))
+ type=3;
+ if(!strncasecmp(&name[l-4], ".ttf", 4))
+ type=2;
+ if(type)
+ {
+ char*fontname = (char*)malloc(strlen(dirname)+strlen(name)+2);
+ strcpy(fontname, dirname);
+ strcat(fontname, dirseparator());
+ strcat(fontname, name);
+ msg("<verbose> Adding %s to fonts", fontname);
+ pdfswf_addfont(fontname);
+ }
+ }
+ closedir(dir);
+#else
+ msg("<warning> No dirent.h- unable to add font dir %s", dir);
+#endif
+}
+
+
+typedef struct _pdf_doc_internal
+{
+ int protect;
+ PDFDoc*doc;
+ InfoOutputDev*info;
+} pdf_doc_internal_t;
+typedef struct _pdf_page_internal
+{
+} pdf_page_internal_t;
+typedef struct _dev_output_internal
+{
+ SWFOutputDev*outputDev;
+} dev_output_internal_t;
+
+pdf_doc_t* pdf_init(char*filename, char*userPassword)