From 5c5118edc1df7753ffebbacc70e1c3c2730d4886 Mon Sep 17 00:00:00 2001 From: xc-racer99 Date: Sun, 30 Apr 2017 12:36:38 -0700 Subject: [PATCH 1/3] Move num_copies to only the header It's not needed to be at the beginning of every page and messes up duplex printing if it is --- src/job.cc | 6 +++--- src/job.h | 5 +++-- src/main.cc | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/job.cc b/src/job.cc index cc8e201..f5863cd 100644 --- a/src/job.cc +++ b/src/job.cc @@ -73,10 +73,12 @@ void job::write_page_header() { fprintf(out_, "@PJL SET PAGEPROTECT = AUTO\n"); fprintf(out_, "@PJL SET ORIENTATION = PORTRAIT\n"); fprintf(out_, "@PJL ENTER LANGUAGE = PCL\n"); + + fputs("\033E", out_); + fprintf(out_, "\033&l%dX", std::max(1, page_params_.num_copies)); } void job::encode_page(const page_params &page_params, - int num_copies, int lines, int linesize, nextline_fn nextline) { @@ -95,8 +97,6 @@ void job::encode_page(const page_params &page_params, block.add_line(encode_line(line)); std::swap(line, reference); - fputs("\033E", out_); - fprintf(out_, "\033&l%dX", std::max(1, num_copies)); fputs("\033*b1030m", out_); for (int i = 1; i < lines && nextline(line.data()); ++i) { diff --git a/src/job.h b/src/job.h index e3e6d5d..69047a9 100644 --- a/src/job.h +++ b/src/job.h @@ -23,6 +23,7 @@ #include struct page_params { + int num_copies; int resolution; bool economode; std::string sourcetray; @@ -30,7 +31,8 @@ struct page_params { std::string papersize; bool operator==(const page_params &o) const { - return resolution == o.resolution + return num_copies == o.num_copies + && resolution == o.resolution && economode == o.economode && sourcetray == o.sourcetray && mediatype == o.mediatype @@ -46,7 +48,6 @@ class job { ~job(); void encode_page(const page_params ¶ms, - int num_copies, int lines, int linesize, nextline_fn nextline); diff --git a/src/main.cc b/src/main.cc index 32d46ee..284d328 100644 --- a/src/main.cc +++ b/src/main.cc @@ -107,6 +107,7 @@ page_params build_page_params() { }; page_params p = { }; + p.num_copies = header.NumCopies; p.resolution = header.HWResolution[0]; p.economode = header.cupsInteger[10]; p.mediatype = header.MediaType; @@ -182,7 +183,6 @@ int main(int argc, char *argv[]) { dump_page_header(header); } job.encode_page(build_page_params(), - header.NumCopies, header.cupsHeight, header.cupsBytesPerLine, next_line); From 7e59e6147ee6d2233757bc808ef3ac90c077994e Mon Sep 17 00:00:00 2001 From: xc-racer99 Date: Mon, 1 May 2017 12:18:22 -0700 Subject: [PATCH 2/3] Add duplex code for DCP-7065DN The official Brother driver treats Tumble and NoTumble differently, adding &l2S and &l1S respectively to the header. Unfortunately, for me this resulted in missing lines in NoTumble. By treating everything as Tumble and simply sending data rotated 180 for Tumble we get a good quality printout. --- brlaser.drv.in | 1 + src/job.cc | 4 ++++ src/job.h | 2 ++ src/main.cc | 1 + 4 files changed, 8 insertions(+) diff --git a/brlaser.drv.in b/brlaser.drv.in index 9f83b8e..09c65cf 100644 --- a/brlaser.drv.in +++ b/brlaser.drv.in @@ -94,4 +94,5 @@ Option "brlaserEconomode/Toner save mode" Boolean AnySetup 10 Attribute "NickName" "" "Brother DCP-7065DN, using @PACKAGE@ v@VERSION@" Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,HBP;MDL:DCP-7065DN;CLS:PRINTER;CID:Brother Laser Type1;" PCFileName "br7065dn.ppd" + Duplex rotated } diff --git a/src/job.cc b/src/job.cc index f5863cd..206bb11 100644 --- a/src/job.cc +++ b/src/job.cc @@ -76,6 +76,10 @@ void job::write_page_header() { fputs("\033E", out_); fprintf(out_, "\033&l%dX", std::max(1, page_params_.num_copies)); + + if (page_params_.duplex) { + fputs("\033&l2S", out_); + } } void job::encode_page(const page_params &page_params, diff --git a/src/job.h b/src/job.h index 69047a9..f26a78c 100644 --- a/src/job.h +++ b/src/job.h @@ -25,6 +25,7 @@ struct page_params { int num_copies; int resolution; + bool duplex; bool economode; std::string sourcetray; std::string mediatype; @@ -33,6 +34,7 @@ struct page_params { bool operator==(const page_params &o) const { return num_copies == o.num_copies && resolution == o.resolution + && duplex == o.duplex && economode == o.economode && sourcetray == o.sourcetray && mediatype == o.mediatype diff --git a/src/main.cc b/src/main.cc index 284d328..db238eb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -111,6 +111,7 @@ page_params build_page_params() { p.resolution = header.HWResolution[0]; p.economode = header.cupsInteger[10]; p.mediatype = header.MediaType; + p.duplex = header.Duplex; if (header.MediaPosition < sources.size()) p.sourcetray = sources[header.MediaPosition]; From f8021024c477658575dca8561bd2ec36f35c3df9 Mon Sep 17 00:00:00 2001 From: xc-racer99 Date: Mon, 1 May 2017 12:21:28 -0700 Subject: [PATCH 3/3] DCP-7065DN: Don't advertise 300DPI printing The DCP-7065DN only supports 600 and 1200 DPI --- brlaser.drv.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brlaser.drv.in b/brlaser.drv.in index 09c65cf..c250d2f 100644 --- a/brlaser.drv.in +++ b/brlaser.drv.in @@ -33,7 +33,6 @@ Filter application/vnd.cups-raster 33 rastertobrlaser // The 1200dpi mode is weird: we need to send 1200x1200dpi raster // data, but Brother only advertises 1200x600dpi. I wonder what // is going on there. -Resolution k 1 0 0 0 "300dpi/300 DPI" *Resolution k 1 0 0 0 "600dpi/600 DPI" Resolution k 1 0 0 0 "1200dpi/1200HQ" @@ -80,6 +79,7 @@ Option "brlaserEconomode/Toner save mode" Boolean AnySetup 10 Attribute "NickName" "" "Brother DCP-7030, using @PACKAGE@ v@VERSION@" Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,HBP;MDL:DCP-7030;CLS:PRINTER;" PCFileName "br7030.ppd" + Resolution k 1 0 0 0 "300dpi/300 DPI" } { @@ -87,6 +87,7 @@ Option "brlaserEconomode/Toner save mode" Boolean AnySetup 10 Attribute "NickName" "" "Brother DCP-7055, using @PACKAGE@ v@VERSION@" Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,HBP;MDL:DCP-7055;CLS:PRINTER;CID:Brother Laser Type1;" PCFileName "br7055.ppd" + Resolution k 1 0 0 0 "300dpi/300 DPI" } {