Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/ipptransform.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ <h2 id="ipptransform-1.named-options">Named Options</h2>
</p>
<p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>number-up</strong><br>
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.
</p>
<p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>orientation-requested</strong><br>
Specifies the orientation of input pages, 3 for portrait, 4 for landscape, 5 for reverse landscape, and 6 for reverse portrait.
Expand Down
2 changes: 1 addition & 1 deletion man/ipptransform.1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ unittests:

clean:
$(RM) $(TARGETS) $(OBJS)
$(RM) test.log test-cups.log
$(RM) test.log test-cups.log test-ipptransform.log


#
Expand Down Expand Up @@ -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


#
Expand All @@ -124,6 +124,7 @@ unittests: ippeveprinter-static ippfind-static ipptool-static

test: unittests
./run-tests.sh
./test-ipptransform.sh


#
Expand Down
4 changes: 4 additions & 0 deletions tools/ipptransform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions tools/test-8up.conf
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions tools/test-8up.test
Original file line number Diff line number Diff line change
@@ -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
}
116 changes: 116 additions & 0 deletions tools/test-ipptransform.sh
Original file line number Diff line number Diff line change
@@ -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"