From 199259ac8a8f63adbdc2d46ac7ac32fd97cc9dbf Mon Sep 17 00:00:00 2001 From: Evan Miller Date: Mon, 31 May 2021 12:27:24 -0400 Subject: [PATCH] Support for long-edge / short-edge duplexing The "Tumble" option is already gathered from CUPS, but was not being sent to the printer. (Tumble = true corresponds to short-edge duplexing, and Tumble = false means long-edge duplexing.) Replace the cryptic PCL short-edge duplexing command with the PJL commands SET DUPLEX = ON / OFF and SET BINDING = LONGEDGE / SHORTEDGE. Tested on an HL-L2300D. --- src/job.cc | 8 ++++---- src/job.h | 2 ++ src/main.cc | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/job.cc b/src/job.cc index 9212e65..e344170 100644 --- a/src/job.cc +++ b/src/job.cc @@ -73,14 +73,14 @@ void job::write_page_header() { page_params_.papersize.c_str()); fprintf(out_, "@PJL SET PAGEPROTECT = AUTO\n"); fprintf(out_, "@PJL SET ORIENTATION = PORTRAIT\n"); + fprintf(out_, "@PJL SET DUPLEX = %s\n", + page_params_.duplex ? "ON" : "OFF"); + fprintf(out_, "@PJL SET BINDING = %s\n", + page_params_.tumble ? "SHORTEDGE" : "LONGEDGE"); fprintf(out_, "@PJL ENTER LANGUAGE = PCL\n"); 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 bd7a83b..0c0442c 100644 --- a/src/job.h +++ b/src/job.h @@ -27,6 +27,7 @@ struct page_params { int num_copies; int resolution; bool duplex; + bool tumble; bool economode; std::string sourcetray; std::string mediatype; @@ -36,6 +37,7 @@ struct page_params { return num_copies == o.num_copies && resolution == o.resolution && duplex == o.duplex + && tumble == o.tumble && economode == o.economode && sourcetray == o.sourcetray && mediatype == o.mediatype diff --git a/src/main.cc b/src/main.cc index d6232b4..abe0528 100644 --- a/src/main.cc +++ b/src/main.cc @@ -111,6 +111,7 @@ page_params build_page_params(const cups_page_header2_t &header) { p.economode = header.cupsInteger[10]; p.mediatype = header.MediaType; p.duplex = header.Duplex; + p.tumble = header.Tumble; if (header.MediaPosition < sources.size()) p.sourcetray = sources[header.MediaPosition];