diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-03-24 18:52:09 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-03-25 14:28:47 +0000 |
commit | 107ee1a2b735d4de1abee5e67445cc7e8023e300 (patch) | |
tree | 2f772a08a2abf286c28c557f792c9d6a8ed589c1 /source | |
parent | bcfb276b494c7b1825527d14c9bcd4d3736a2ffd (diff) | |
download | mupdf-107ee1a2b735d4de1abee5e67445cc7e8023e300.tar.xz |
Tweak the PCL page size handling/options.
Introduce a 'generic' PCL setting (basically ljet4 with custom
page sizes for now).
Ensure we send explicit sizes before the custom page sizes, and
don't use Ricoh page sizes unless we are allowed to.
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/output-pcl.c | 24 | ||||
-rw-r--r-- | source/tools/mudraw.c | 2 |
2 files changed, 21 insertions, 5 deletions
diff --git a/source/fitz/output-pcl.c b/source/fitz/output-pcl.c index 57116b79..7a4dc31e 100644 --- a/source/fitz/output-pcl.c +++ b/source/fitz/output-pcl.c @@ -35,6 +35,7 @@ #define HACK__IS_A_OCE9050 1024 #define PCL_HAS_ORIENTATION 2048 #define PCL_CAN_SET_CUSTOM_PAPER_SIZE 4096 +#define PCL_HAS_RICOH_PAPER_SIZES 8192 /* Shorthands for the most common spacing/compression combinations. */ #define PCL_MODE0 PCL3_SPACING @@ -50,6 +51,14 @@ static const char *const from3to2 = "\033*b2M"; static const int penalty_from2to3 = 5; /* strlen(from2to3); */ static const int penalty_from3to2 = 5; /* strlen(from3to2); */ +/* Generic */ +static const fz_pcl_options fz_pcl_options_generic = +{ + (PCL_MODE2 | PCL_END_GRAPHICS_DOES_RESET | PCL_CAN_SET_PAPER_SIZE | PCL_CAN_SET_CUSTOM_PAPER_SIZE), + "\033&k1W\033*b2M", + "\033&k1W\033*b2M" +}; + /* H-P DeskJet */ static const fz_pcl_options fz_pcl_options_ljet4 = { @@ -200,7 +209,9 @@ static void copy_opts(fz_pcl_options *dst, const fz_pcl_options *src) void fz_pcl_preset(fz_context *ctx, fz_pcl_options *opts, const char *preset) { - if (preset == NULL || *preset == 0 || !strcmp(preset, "ljet4")) + if (preset == NULL || *preset == 0 || !strcmp(preset, "generic")) + copy_opts(opts, &fz_pcl_options_generic); + else if (!strcmp(preset, "ljet4")) copy_opts(opts, &fz_pcl_options_ljet4); else if (!strcmp(preset, "dj500")) copy_opts(opts, &fz_pcl_options_dj500); @@ -371,8 +382,7 @@ pcl_header(fz_context *ctx, fz_output *out, fz_pcl_options *pcl, int num_copies, /* based on the actual requested size. */ if (pcl->features & PCL_CAN_SET_PAPER_SIZE) { - fz_printf(ctx, out, "\033&l%dA", pcl->paper_size); - if ((pcl->features & PCL_CAN_SET_CUSTOM_PAPER_SIZE) != 0 && pcl->paper_size == eCustomPaperSize) + /* It probably never hurts to define the page explicitly */ { int decipointw = (w * 720 + (xres>>1)) / xres; int decipointh = (h * 720 + (yres>>1)) / yres; @@ -380,6 +390,7 @@ pcl_header(fz_context *ctx, fz_output *out, fz_pcl_options *pcl, int num_copies, fz_printf(ctx, out, "\033&f%dI", decipointw); fz_printf(ctx, out, "\033&f%dJ", decipointh); } + fz_printf(ctx, out, "\033&l%dA", pcl->paper_size); } /* If printer can duplex, set duplex mode appropriately. */ if (pcl->features & PCL_HAS_DUPLEX) @@ -529,6 +540,8 @@ static void guess_paper_size(fz_pcl_options *pcl, int w, int h, int xres, int yr /* Look for an exact match */ for (size = 0; size < num_elems(papersizes); size++) { + if (papersizes[size].code > eCustomPaperSize && (pcl->features & PCL_HAS_RICOH_PAPER_SIZES) == 0) + continue; if (w == papersizes[size].width && h == papersizes[size].height) break; if ((pcl->features & PCL_HAS_ORIENTATION) && w == papersizes[size].height && h == papersizes[size].width) @@ -554,7 +567,10 @@ static void guess_paper_size(fz_pcl_options *pcl, int w, int h, int xres, int yr int best_waste = INT_MAX; for (i = 0; i < num_elems(papersizes); i++) { - int waste = papersizes[i].width * papersizes[i].height - w * h; + int waste; + if (papersizes[i].code > eCustomPaperSize && (pcl->features & PCL_HAS_RICOH_PAPER_SIZES) == 0) + continue; + waste = papersizes[i].width * papersizes[i].height - w * h; if (waste > best_waste) continue; if (w <= papersizes[i].width && h <= papersizes[i].height) diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index ac054996..33c299e0 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -689,7 +689,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) { fz_pcl_options options; - fz_pcl_preset(ctx, &options, "ljet4"); + fz_pcl_preset(ctx, &options, "generic"); if (out_cs == CS_MONO) { |