From bf25871ae142a83cfe7e11cc0915f7978e721c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lipinsk=C3=BD?= <6032558+Mr-Tao@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:31:46 +0200 Subject: [PATCH] Add 8-up support to ipptransform --- doc/ipptransform.html | 2 +- man/ipptransform.1 | 2 +- tools/Makefile | 5 +- tools/ipptransform.c | 4 ++ tools/test-8up.conf | 14 +++++ tools/test-8up.test | 60 +++++++++++++++++++ tools/test-ipptransform.sh | 116 +++++++++++++++++++++++++++++++++++++ 7 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 tools/test-8up.conf create mode 100644 tools/test-8up.test create mode 100755 tools/test-ipptransform.sh diff --git a/doc/ipptransform.html b/doc/ipptransform.html index 0ebd8e0ee..5e0ba7820 100644 --- a/doc/ipptransform.html +++ b/doc/ipptransform.html @@ -235,7 +235,7 @@
number-up
Specifies the number of input pages to impose on each output page.
-The values 1, 2, 4, 6, 9, 12, and 16 are supported.
+The values 1, 2, 4, 6, 8, 9, 12, and 16 are supported.
orientation-requested
Specifies the orientation of input pages, 3 for portrait, 4 for landscape, 5 for reverse landscape, and 6 for reverse portrait.
diff --git a/man/ipptransform.1 b/man/ipptransform.1
index f3ddacdc4..a2b490335 100644
--- a/man/ipptransform.1
+++ b/man/ipptransform.1
@@ -143,7 +143,7 @@ Specifies whether to produce uncollated ("separate-documents-uncollated-copies")
.TP 5
.B number\-up
Specifies the number of input pages to impose on each output page.
-The values 1, 2, 4, 6, 9, 12, and 16 are supported.
+The values 1, 2, 4, 6, 8, 9, 12, and 16 are supported.
.TP 5
.B orientation\-requested
Specifies the orientation of input pages, 3 for portrait, 4 for landscape, 5 for reverse landscape, and 6 for reverse portrait.
diff --git a/tools/Makefile b/tools/Makefile
index 4c168f844..21c0f113a 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -54,7 +54,7 @@ unittests:
clean:
$(RM) $(TARGETS) $(OBJS)
- $(RM) test.log test-cups.log
+ $(RM) test.log test-cups.log test-ipptransform.log
#
@@ -115,7 +115,7 @@ uninstall:
# Unit test programs (not built when cross-compiling...)
#
-unittests: ippeveprinter-static ippfind-static ipptool-static
+unittests: ippeveprinter-static ippfind-static ipptool-static ipptransform-static
#
@@ -124,6 +124,7 @@ unittests: ippeveprinter-static ippfind-static ipptool-static
test: unittests
./run-tests.sh
+ ./test-ipptransform.sh
#
diff --git a/tools/ipptransform.c b/tools/ipptransform.c
index 53be339aa..a5e82f955 100644
--- a/tools/ipptransform.c
+++ b/tools/ipptransform.c
@@ -3665,6 +3665,10 @@ prepare_number_up(xform_prepare_t *p) // I - Preparation data
cols = 2;
rows = 3;
break;
+ case 8 : // 8-up
+ cols = 2;
+ rows = 4;
+ break;
case 9 : // 9-up
cols = 3;
rows = 3;
diff --git a/tools/test-8up.conf b/tools/test-8up.conf
new file mode 100644
index 000000000..edf119136
--- /dev/null
+++ b/tools/test-8up.conf
@@ -0,0 +1,14 @@
+#
+# 8-up test printer configuration file.
+#
+# Copyright © 2026 by OpenPrinting.
+#
+# Licensed under Apache License v2.0. See the file "LICENSE" for more
+# information.
+#
+
+ATTR mimeMediaType document-format-default application/pdf
+ATTR mimeMediaType document-format-supported application/pdf
+
+ATTR integer number-up-default 1
+ATTR integer number-up-supported 1,2,4,6,8,9,12,16
diff --git a/tools/test-8up.test b/tools/test-8up.test
new file mode 100644
index 000000000..c02d9a3a0
--- /dev/null
+++ b/tools/test-8up.test
@@ -0,0 +1,60 @@
+#
+# Test 8-up printing through an IPP Everywhere printer.
+#
+# Copyright © 2026 by OpenPrinting.
+#
+# Licensed under Apache License v2.0. See the file "LICENSE" for more
+# information.
+#
+
+{
+ NAME "Get 8-up printer capabilities"
+ OPERATION Get-Printer-Attributes
+ GROUP operation-attributes-tag
+ ATTR charset attributes-charset utf-8
+ ATTR naturalLanguage attributes-natural-language en
+ ATTR uri printer-uri $uri
+ ATTR keyword requested-attributes number-up-default,number-up-supported
+
+ STATUS successful-ok
+ EXPECT number-up-default OF-TYPE integer COUNT 1 IN-GROUP printer-attributes-tag WITH-VALUE 1
+ EXPECT number-up-supported OF-TYPE integer IN-GROUP printer-attributes-tag WITH-VALUE 8
+}
+
+{
+ NAME "Print 8-up PDF"
+ OPERATION Print-Job
+ GROUP operation-attributes-tag
+ ATTR charset attributes-charset utf-8
+ ATTR naturalLanguage attributes-natural-language en
+ ATTR uri printer-uri $uri
+ ATTR name requesting-user-name $user
+ ATTR name job-name "8-Up Test"
+ ATTR boolean ipp-attribute-fidelity true
+ ATTR name document-name $filename
+ ATTR mimeMediaType document-format application/pdf
+ GROUP job-attributes-tag
+ ATTR integer number-up 8
+ FILE $filename
+
+ STATUS successful-ok
+ EXPECT job-id OF-TYPE integer COUNT 1 IN-GROUP job-attributes-tag WITH-VALUE >0
+ EXPECT job-uri OF-TYPE uri COUNT 1 IN-GROUP job-attributes-tag
+}
+
+{
+ NAME "Wait for 8-up job to complete"
+ OPERATION Get-Job-Attributes
+ GROUP operation-attributes-tag
+ ATTR charset attributes-charset utf-8
+ ATTR naturalLanguage attributes-natural-language en
+ ATTR uri printer-uri $uri
+ ATTR integer job-id $job-id
+ ATTR name requesting-user-name $user
+
+ STATUS successful-ok
+ EXPECT number-up OF-TYPE integer COUNT 1 IN-GROUP job-attributes-tag WITH-VALUE 8
+ EXPECT job-state OF-TYPE enum COUNT 1 IN-GROUP job-attributes-tag WITH-VALUE 7,8,9 REPEAT-NO-MATCH REPEAT-LIMIT 30
+ EXPECT job-state OF-TYPE enum COUNT 1 IN-GROUP job-attributes-tag WITH-VALUE 9
+ EXPECT job-state-reasons OF-TYPE keyword IN-GROUP job-attributes-tag WITH-VALUE job-completed-successfully
+}
diff --git a/tools/test-ipptransform.sh b/tools/test-ipptransform.sh
new file mode 100755
index 000000000..9961f7731
--- /dev/null
+++ b/tools/test-ipptransform.sh
@@ -0,0 +1,116 @@
+#!/bin/sh
+#
+# Test ipptransform directly and through a virtual IPP Everywhere printer.
+#
+# Copyright © 2026 by OpenPrinting.
+#
+# Licensed under Apache License v2.0. See the file "LICENSE" for more
+# information.
+#
+
+cd .. || exit 1
+
+name="8-Up Test Printer $(date +%H%M%S)-$$"
+status=0
+testdir="${TMPDIR:-/tmp}/libcups-8up-$$"
+printer=""
+
+cleanup()
+{
+ if test -n "$printer"; then
+ kill "$printer" 2>/dev/null
+ wait "$printer" 2>/dev/null
+ fi
+
+ rm -rf "$testdir"
+}
+
+if ! mkdir "$testdir"; then
+ echo "Unable to create 8-up test directory '$testdir'."
+ exit 1
+fi
+
+trap cleanup 0
+trap 'exit 1' 1 2 3 15
+
+unset CONTENT_TYPE OUTPUT_TYPE DEVICE_URI IPP_NUMBER_UP
+
+rm -f tools/test-ipptransform.log
+
+echo "Running ipptransform directly..."
+if ! tools/ipptransform-static -v \
+ -f "$testdir/direct.pdf" \
+ -i application/pdf \
+ -m application/pdf \
+ -o "number-up=8" \
+ examples/testfile.pdf >"$testdir/direct.log" 2>&1; then
+ echo "Direct 8-up conversion failed."
+ status=1
+fi
+
+if ! test -s "$testdir/direct.pdf"; then
+ echo "Direct 8-up conversion did not produce an output document."
+ status=1
+fi
+
+if ! grep -q "Using page 8 .*cell=8/8, current=0" "$testdir/direct.log" || \
+ ! grep -q "Doing full layout of 1 pages." "$testdir/direct.log" || \
+ ! grep -q "Page 1, cell 8/8" "$testdir/direct.log"; then
+ echo "Direct conversion did not group all eight input pages on one output page."
+ status=1
+fi
+
+echo "Running ipptransform through ippeveprinter..."
+SERVER_LOGLEVEL=debug tools/ippeveprinter-static -vvv \
+ -a tools/test-8up.conf \
+ -c "$PWD/tools/ipptransform-static" \
+ -d "$testdir" \
+ -F application/pdf \
+ -k \
+ -n localhost \
+ -L tools/test-ipptransform.log \
+ "$name" &
+printer=$!
+
+if ! tools/ippfind-static -T 30 "$name" \
+ --exec tools/ipptool-static -V 2.0 -tf examples/testfile.pdf \
+ '{}' tools/test-8up.test \;
+then
+ echo "Unable to test the virtual 8-up printer."
+ status=1
+fi
+
+if ! grep -q "number-up (integer) 8" tools/test-ipptransform.log; then
+ echo "8-up job attribute was not received by ippeveprinter."
+ status=1
+fi
+
+if ! grep -q "Using page 8 .*cell=8/8, current=0" tools/test-ipptransform.log; then
+ echo "ipptransform did not group all eight input pages on one output page."
+ status=1
+fi
+
+if ! grep -q "Doing full layout of 1 pages." tools/test-ipptransform.log || \
+ ! grep -q "Page 1, cell 8/8" tools/test-ipptransform.log; then
+ echo "ipptransform did not produce the expected 8-up layout."
+ status=1
+fi
+
+outputs=0
+for file in "$testdir"/*.prn; do
+ if test -f "$file"; then
+ outputs=$((outputs + 1))
+
+ if ! test -s "$file"; then
+ echo "ipptransform produced an empty output document."
+ status=1
+ fi
+ fi
+done
+
+if test "$outputs" -ne 1; then
+ echo "Expected one output document, found $outputs."
+ status=1
+fi
+
+exit "$status"