summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-04-07 13:49:31 +0200
committerRobin Watts <robin.watts@artifex.com>2015-04-07 13:35:08 +0100
commit0ccfd9c40b6790fca0f753e03b473b5f78ba97f9 (patch)
tree6dfc359cb0a88a4bc887672bf7048a6c5337d74e
parentb8eb55a488aa9dc6884e01b06e948faf1f83012d (diff)
downloadmupdf-0ccfd9c40b6790fca0f753e03b473b5f78ba97f9.tar.xz
Add EPUB layout options to mupdf-x11 and mudraw.
-rw-r--r--docs/man/mudraw.19
-rw-r--r--docs/man/mupdf.113
-rw-r--r--platform/x11/pdfapp.c7
-rw-r--r--platform/x11/pdfapp.h4
-rw-r--r--platform/x11/x11_main.c33
-rw-r--r--source/tools/mudraw.c16
6 files changed, 61 insertions, 21 deletions
diff --git a/docs/man/mudraw.1 b/docs/man/mudraw.1
index 9d08b99f..390e78c1 100644
--- a/docs/man/mudraw.1
+++ b/docs/man/mudraw.1
@@ -57,6 +57,15 @@ render with a maximum height).
.B \-f
Fit exactly; ignore the aspect ratio when matching specified width/heights.
.TP
+.B \-W width
+Page width in points for EPUB layout.
+.TP
+.B \-H height
+Page height in points for EPUB layout.
+.TP
+.B \-S size
+Font size in points for EPUB layout.
+.TP
.B \-c colorspace
Render in the specified colorspace.
Supported colorspaces are: mono, gray, grayalpha, rgb, rgbalpha, cmyk, cmykalpha.
diff --git a/docs/man/mupdf.1 b/docs/man/mupdf.1
index 44a6a600..42d80118 100644
--- a/docs/man/mupdf.1
+++ b/docs/man/mupdf.1
@@ -1,4 +1,4 @@
-.TH MUPDF 1 "July 25, 2013"
+.TH MUPDF 1 "April 7, 2015"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -26,13 +26,22 @@ The password is tried both as user and owner password.
Changes the initial zoom level, specified as the resolution in dpi.
The default value is 72.
.TP
-.B \-b bits
+.B \-A bits
Changes the anti-aliasing quality, specified as a number of bits between 0
(off) and 8 (best). The default value is 8.
.TP
.B \-C RRGGBB
Sets the full-page tint using hexadecimal color syntax. The default value
is FFFAF0.
+.TP
+.B \-W width
+Page width in points for EPUB layout.
+.TP
+.B \-H height
+Page height in points for EPUB layout.
+.TP
+.B \-S size
+Font size in points for EPUB layout.
.SH MOUSE BEHAVIOR
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index 651b3844..3d727ed1 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -115,6 +115,11 @@ void pdfapp_init(fz_context *ctx, pdfapp_t *app)
app->scrh = 480;
app->resolution = 72;
app->ctx = ctx;
+
+ app->layout_w = 450;
+ app->layout_h = 600;
+ app->layout_em = 12;
+
app->transition.duration = 0.25;
app->transition.type = FZ_TRANSITION_FADE;
#if defined(_WIN32) || defined(_WIN64)
@@ -389,6 +394,8 @@ void pdfapp_open_progressive(pdfapp_t *app, char *filename, int reload, int bps)
app->doctitle = strrchr(app->doctitle, '/') + 1;
app->doctitle = fz_strdup(ctx, app->doctitle);
+ fz_layout_document(app->ctx, app->doc, app->layout_w, app->layout_h, app->layout_em);
+
while (1)
{
fz_try(ctx)
diff --git a/platform/x11/pdfapp.h b/platform/x11/pdfapp.h
index 5d748ad6..46f09640 100644
--- a/platform/x11/pdfapp.h
+++ b/platform/x11/pdfapp.h
@@ -54,6 +54,10 @@ struct pdfapp_s
fz_outline *outline;
int outline_deferred;
+ float layout_w;
+ float layout_h;
+ float layout_em;
+
int pagecount;
/* current view params */
diff --git a/platform/x11/x11_main.c b/platform/x11/x11_main.c
index 0da79469..80c86a23 100644
--- a/platform/x11/x11_main.c
+++ b/platform/x11/x11_main.c
@@ -798,10 +798,13 @@ static void signal_handler(int signal)
static void usage(void)
{
fprintf(stderr, "usage: mupdf [options] file.pdf [page]\n");
- fprintf(stderr, "\t-b -\tset anti-aliasing quality in bits (0=off, 8=best)\n");
fprintf(stderr, "\t-p -\tpassword\n");
fprintf(stderr, "\t-r -\tresolution\n");
+ fprintf(stderr, "\t-A -\tset anti-aliasing quality in bits (0=off, 8=best)\n");
fprintf(stderr, "\t-C -\tRRGGBB (tint color in hexadecimal syntax)\n");
+ fprintf(stderr, "\t-W -\tpage width for EPUB layout\n");
+ fprintf(stderr, "\t-H -\tpage height for EPUB layout\n");
+ fprintf(stderr, "\t-S -\tfont size for EPUB layout\n");
exit(1);
}
@@ -822,8 +825,6 @@ int main(int argc, char **argv)
struct timeval now;
struct timeval *timeout;
struct timeval tmo_advance_delay;
- int tint = 0;
- int tint_r, tint_g, tint_b;
ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
if (!ctx)
@@ -832,20 +833,25 @@ int main(int argc, char **argv)
exit(1);
}
- while ((c = fz_getopt(argc, argv, "p:r:b:C:")) != -1)
+ pdfapp_init(ctx, &gapp);
+
+ while ((c = fz_getopt(argc, argv, "p:r:A:C:W:H:S:")) != -1)
{
switch (c)
{
case 'C':
c = strtol(fz_optarg, NULL, 16);
- tint = 1;
- tint_r = (c >> 16) & 255;
- tint_g = (c >> 8) & 255;
- tint_b = (c) & 255;
+ gapp.tint = 1;
+ gapp.tint_r = (c >> 16) & 255;
+ gapp.tint_g = (c >> 8) & 255;
+ gapp.tint_b = (c) & 255;
break;
case 'p': password = fz_optarg; break;
case 'r': resolution = atoi(fz_optarg); break;
- case 'b': fz_set_aa_level(ctx, atoi(fz_optarg)); break;
+ case 'A': fz_set_aa_level(ctx, atoi(fz_optarg)); break;
+ case 'W': gapp.layout_w = fz_atof(fz_optarg); break;
+ case 'H': gapp.layout_h = fz_atof(fz_optarg); break;
+ case 'S': gapp.layout_em = fz_atof(fz_optarg); break;
default: usage();
}
}
@@ -858,15 +864,6 @@ int main(int argc, char **argv)
if (argc - fz_optind == 1)
pageno = atoi(argv[fz_optind++]);
- pdfapp_init(ctx, &gapp);
- if (tint)
- {
- gapp.tint = tint;
- gapp.tint_r = tint_r;
- gapp.tint_g = tint_g;
- gapp.tint_b = tint_b;
- }
-
winopen();
if (resolution == -1)
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index 8edcf381..75e32e5c 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -113,6 +113,10 @@ static int width = 0;
static int height = 0;
static int fit = 0;
+static float layout_w = 450;
+static float layout_h = 600;
+static float layout_em = 12;
+
static int showfeatures = 0;
static int showtime = 0;
static size_t memtrace_current = 0;
@@ -174,6 +178,10 @@ static void usage(void)
"\t-f -\tfit width and/or height exactly; ignore original aspect ratio\n"
"\t-B -\tmaximum bandheight (pgm, ppm, pam, png output only)\n"
"\n"
+ "\t-W -\tpage width for EPUB layout\n"
+ "\t-H -\tpage height for EPUB layout\n"
+ "\t-S -\tfont size for EPUB layout\n"
+ "\n"
"\t-c -\tcolorspace (mono, gray, grayalpha, rgb, rgba, cmyk, cmykalpha)\n"
"\t-G -\tapply gamma correction\n"
"\t-I\tinvert colors\n"
@@ -848,7 +856,7 @@ int main(int argc, char **argv)
fz_var(doc);
- while ((c = fz_getopt(argc, argv, "po:F:R:r:w:h:fB:c:G:I:s:A:Di")) != -1)
+ while ((c = fz_getopt(argc, argv, "po:F:R:r:w:h:fB:c:G:I:s:A:DiW:H:S:")) != -1)
{
switch (c)
{
@@ -870,6 +878,10 @@ int main(int argc, char **argv)
case 'G': gamma_value = atof(fz_optarg); break;
case 'I': invert++; break;
+ case 'W': layout_w = atof(fz_optarg); break;
+ case 'H': layout_h = atof(fz_optarg); break;
+ case 'S': layout_em = atof(fz_optarg); break;
+
case 's':
if (strchr(fz_optarg, 't')) ++showtime;
if (strchr(fz_optarg, 'm')) ++showmemory;
@@ -1060,6 +1072,8 @@ int main(int argc, char **argv)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot authenticate password: %s", filename);
}
+ fz_layout_document(ctx, doc, layout_w, layout_h, layout_em);
+
if (output_format == OUT_STEXT || output_format == OUT_TRACE)
fz_printf(ctx, out, "<document name=\"%s\">\n", filename);