>From 14804dd48e2bbcd662a7127ef55ba803f685c6e2 Mon Sep 17 00:00:00 2001
From: Peter Sagi <ps...@freemail.hu>
Date: Sun, 24 Jul 2022 09:57:24 +0000
Subject: [PATCH] Fix the misaligned printed image for smaller paper-sizes on
 LaserJet 1100. Closes: #1015911.

---
 Normalize.cpp                   |  3 ++-
 Normalize.h                     |  2 +-
 base/models.py                  |  3 ++-
 data/models/models.dat          |  6 +++---
 prnt/drv/hpcups.drv.in.template | 16 +++++++++++++++-
 prnt/hpcups/Encapsulator.cpp    | 16 ++++++++--------
 6 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/Normalize.cpp b/Normalize.cpp
index afbd356..65df257 100644
--- a/Normalize.cpp
+++ b/Normalize.cpp
@@ -119,7 +119,8 @@ string TECH_SUBCLASSES[MAX_SUB_CLASS] = {
     "Mono_Duplex",
     "AutoDuplex",
     "K10",
-    "CuHdIPH"
+    "CuHdIPH",
+    "CenterAligned"
 };
 
 /** string array of shortening replacements                 */
diff --git a/Normalize.h b/Normalize.h
index 0839174..fe5cb67 100644
--- a/Normalize.h
+++ b/Normalize.h
@@ -6,7 +6,7 @@
 #define MAX_TECH_CLASS_PDL                 67
 #define MAX_TECH_CLASS                     77
 #define MAX_FAMILY_CLASS                   54
-#define MAX_SUB_CLASS                      32
+#define MAX_SUB_CLASS                      33
 
 
 #define COLOR                              "Color"
diff --git a/base/models.py b/base/models.py
index 46c44e4..5776831 100644
--- a/base/models.py
+++ b/base/models.py
@@ -272,7 +272,8 @@ TECH_SUBCLASSES = [
     "Mono_Duplex",
     "AutoDuplex",
     "K10",
-    "CuHdIPH"
+    "CuHdIPH",
+    "CenterAligned"
 ]
 
 TECH_SUBCLASSES.sort()
diff --git a/data/models/models.dat b/data/models/models.dat
index 113cf26..fc3ef33 100644
--- a/data/models/models.dat
+++ b/data/models/models.dat
@@ -18504,7 +18504,7 @@ support-type=2
 support-ver=0.9.5
 tech-class=LJMono
 family-class=LJ-Class6
-tech-subclass=Normal
+tech-subclass=CenterAligned
 tech-type=3
 usb-pid=0
 usb-vid=3f0
@@ -18587,7 +18587,7 @@ support-type=2
 support-ver=0.9.5
 tech-class=LJMono
 family-class=LJ-Class6
-tech-subclass=Normal
+tech-subclass=CenterAligned
 tech-type=3
 usb-pid=0
 usb-vid=3f0
@@ -18830,7 +18830,7 @@ support-type=2
 support-ver=0.9.5
 tech-class=LJMono
 family-class=LJ-Class6
-tech-subclass=Normal
+tech-subclass=CenterAligned
 tech-type=3
 usb-pid=0
 usb-vid=3f0
diff --git a/prnt/drv/hpcups.drv.in.template b/prnt/drv/hpcups.drv.in.template
index 9dddc2b..351e966 100644
--- a/prnt/drv/hpcups.drv.in.template
+++ b/prnt/drv/hpcups.drv.in.template
@@ -13730,6 +13730,12 @@ Group "RLT/HP Real Life Technologies"
     Choice "Draft/Draft (Economy)" "<</OutputType(-1)/HWResolution[300 300]>>setpagedevice"
     Choice "Best/Best" "<</OutputType(0)/HWResolution[600 600]>>setpagedevice"
 
+  /*  Dummy option to handle the center-aligned paper guide feature of the
+      LaserJet 1100 family */
+  Option "PaperAlignment/Paper Alignment" PickOne AnySetup 10.0
+   *Choice "Left" ""
+   Choice "Center" "<</cupsInteger1 783>>setpagedevice"
+
   // Duplexer is optional...
   Installable "OptionDuplex/Duplexer Installed"
 
@@ -13805,11 +13811,19 @@ Group "RLT/HP Real Life Technologies"
     MinSize 1in 4in
     MaxSize 8.5in 14in
 
-    // <%LJMono:Normal%>
     {
+      UIConstraints "*PaperAlignment Center *MediaType" 
+      // <%LJMono:Normal%>
+    }
+    {
+      UIConstraints "*PaperAlignment Center *MediaType" 
       UIConstraints "*OutputMode Best *MediaType"
       // <%LJMono:300dpiOnly%>
     }
+    {
+      UIConstraints "*PaperAlignment Left *MediaType"
+      // <%LJMono:CenterAligned%>
+    }
   } // End Supported media sizes.
 
   {
diff --git a/prnt/hpcups/Encapsulator.cpp b/prnt/hpcups/Encapsulator.cpp
index e661f4a..9e78033 100644
--- a/prnt/hpcups/Encapsulator.cpp
+++ b/prnt/hpcups/Encapsulator.cpp
@@ -255,6 +255,14 @@ void Encapsulator::sendJobHeader()
         addToHeader((const BYTE *) szStr, 20);
     }
 
+    top_margin = m_pMA->printable_start_y - ((m_pJA->mech_offset * m_pQA->actual_vertical_resolution)/1000);
+    int left_margin = 0;
+    if (m_pJA->integer_values[1] > 0)
+    {
+        left_margin = ((m_pJA->integer_values[1] * m_pQA->horizontal_resolution) / 100 - m_pMA->printable_width) / 2;
+    }
+    addToHeader("\x1b*p%dx%dY", left_margin, top_margin);
+
     const BYTE *pgrafMode = grafMode2;
     if (m_pJA->color_mode == 0)
     {
@@ -266,14 +274,6 @@ void Encapsulator::sendJobHeader()
     addToHeader((const BYTE *) pgrafMode, 5);
     addToHeader((const BYTE *) seedSame, sizeof(seedSame));
 
-    top_margin = m_pMA->printable_start_y - ((m_pJA->mech_offset * m_pQA->actual_vertical_resolution)/1000);
-    int left_margin = 0;
-    if (m_pJA->integer_values[1] > 0)
-    {
-        left_margin = ((m_pJA->integer_values[1] * m_pQA->horizontal_resolution) / 100 - m_pMA->printable_width) / 2;
-    }
-    addToHeader("\x1b*p%dx%dY", left_margin, top_margin);
-
     return;
 }
 
-- 
2.36.1

Reply via email to