+#include <stdio.h>
+#include <string.h>
#include "../gfxdevice.h"
#include "../gfxsource.h"
#include "../devices/rescale.h"
#include "../args.h"
static double zoom = 72; /* xpdf: 86 */
-static int jpeg_dpi = 0;
-static int ppm_dpi = 0;
+static int zoomtowidth = 0;
static int multiply = 1;
static char* global_page_range = 0;
sprintf(buf, "%.1f", i->doc->getPDFVersion());
return strdup(buf);
}
- return 0;
+ return strdup("");
}
+/* shortcut to InfoOutputDev.cc */
+extern int config_addspace;
+extern int config_fontquality;
+extern int config_bigchar;
+
static void pdf_set_parameter(gfxsource_t*src, const char*name, const char*value)
{
gfxsource_internal_t*i = (gfxsource_internal_t*)src->internal;
- parameterlist_t*p = &i->parameters;
+
msg("<verbose> setting parameter %s to \"%s\"", name, value);
if(!strncmp(name, "fontdir", strlen("fontdir"))) {
addGlobalFontDir(value);
+ } else if(!strcmp(name, "detectspaces")) {
+ config_addspace = atoi(value);
+ } else if(!strcmp(name, "fontquality")) {
+ config_fontquality = atoi(value);
+ } else if(!strcmp(name, "bigchar")) {
+ config_bigchar = atoi(value);
} else if(!strcmp(name, "pages")) {
global_page_range = strdup(value);
} else if(!strncmp(name, "font", strlen("font")) && name[4]!='q') {
addGlobalFont(value);
} else if(!strncmp(name, "languagedir", strlen("languagedir"))) {
addGlobalLanguageDir(value);
+ } else if(!strcmp(name, "zoomtowidth")) {
+ zoomtowidth = atoi(value);
} else if(!strcmp(name, "zoom")) {
char buf[80];
zoom = atof(value);
- sprintf(buf, "%f", (double)jpeg_dpi/(double)zoom);
- storeDeviceParameter(p, "jpegsubpixels", buf);
- sprintf(buf, "%f", (double)ppm_dpi/(double)zoom);
- storeDeviceParameter(p, "ppmsubpixels", buf);
- } else if(!strcmp(name, "jpegdpi")) {
- char buf[80];
- jpeg_dpi = atoi(value);
- sprintf(buf, "%f", (double)jpeg_dpi/(double)zoom);
- storeDeviceParameter(p, "jpegsubpixels", buf);
- } else if(!strcmp(name, "ppmdpi")) {
- char buf[80];
- ppm_dpi = atoi(value);
- sprintf(buf, "%f", (double)ppm_dpi/(double)zoom);
- storeDeviceParameter(p, "ppmsubpixels", buf);
+ } else if(!strcmp(name, "jpegdpi") || !strcmp(name, "ppmdpi")) {
+ msg("<error> %s not supported anymore. Please use jpegsubpixels/ppmsubpixels");
} else if(!strcmp(name, "multiply")) {
multiply = atoi(value);
} else if(!strcmp(name, "help")) {
i->filename = strdup(filename);
char*x = 0;
- if((x = strchr(filename, '|'))) {
+ if((x = strchr((char*)filename, '|'))) {
*x = 0;
userPassword = x+1;
}
if(!i->doc->okToChange() || !i->doc->okToAddNotes())
i->protect = 1;
}
+
+ if(zoomtowidth && i->doc->getNumPages()) {
+ Page*page = i->doc->getCatalog()->getPage(1);
+ PDFRectangle *r = page->getCropBox();
+ double width_before = r->x2 - r->x1;
+ zoom = 72.0 * zoomtowidth / width_before;
+ msg("<notice> Rendering at %f DPI. (Page width at 72 DPI: %f, target width: %d)", zoom, width_before, zoomtowidth);
+ }
i->info = new InfoOutputDev(i->doc->getXRef());
int t;