Printing in Black&white With Ipptool
Fleetingprinting in black&white with ipptool
Reading the documentation of IPP, I understand I need to add a job attribute to set the color.
Finding out the available attributes in my printer
clk pdf print . --command get-job-template-attributes |gi color-mode
print-color-mode-supported (1setOf keyword) = monochrome,color
print-color-mode-default (keyword) = color
I need to provide this job, in a job attribute group.
There is already an ipp test file to print with the default attributes.
cat /usr/share/cups/ipptool/print-job-and-wait.test
# Print a test page using print-job
{
# The name of the test...
NAME "Print file using Print-Job"
# The operation to use
OPERATION Print-Job
# Attributes, starting in the operation group...
GROUP operation-attributes-tag
ATTR charset attributes-charset utf-8
ATTR language attributes-natural-language en
ATTR uri printer-uri $uri
ATTR name requesting-user-name $user
ATTR mimeMediaType document-format $filetype
GROUP job-attributes-tag
ATTR integer copies 1
FILE $filename
# What statuses are OK?
STATUS successful-ok
STATUS successful-ok-ignored-or-substituted-attributes
# What attributes do we expect?
EXPECT job-id
EXPECT job-uri
}
{
NAME "Wait for job to complete..."
OPERATION Get-Job-Attributes
GROUP operation-attributes-tag
ATTR charset attributes-charset utf-8
ATTR language 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 job-id
EXPECT job-state WITH-VALUE >5 REPEAT-NO-MATCH
DISPLAY job-state
DISPLAY job-state-reasons
}
I can simply copy this one and add the monochrome job attribute.
clk pdf print --command - somefile <<EOF
# Print a test page using print-job
{
# The name of the test...
NAME "Print file using Print-Job"
# The operation to use
OPERATION Print-Job
# Attributes, starting in the operation group...
GROUP operation-attributes-tag
ATTR charset attributes-charset utf-8
ATTR language attributes-natural-language en
ATTR uri printer-uri $uri
ATTR name requesting-user-name $user
ATTR mimeMediaType document-format $filetype
GROUP job-attributes-tag
ATTR integer copies 1
ATTR keyword print-color-mode monochrome
FILE $filename
# What statuses are OK?
STATUS successful-ok
STATUS successful-ok-ignored-or-substituted-attributes
# What attributes do we expect?
EXPECT job-id
EXPECT job-uri
}
{
NAME "Wait for job to complete..."
OPERATION Get-Job-Attributes
GROUP operation-attributes-tag
ATTR charset attributes-charset utf-8
ATTR language 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 job-id
EXPECT job-state WITH-VALUE >5 REPEAT-NO-MATCH
DISPLAY job-state
DISPLAY job-state-reasons
}
EOF
Print-Job:
attributes-charset (charset) = utf-8
attributes-natural-language (naturalLanguage) = en
printer-uri (uri) = ipp://127.0.0.1:8080/printers/Canon_MG5700_series
requesting-user-name (nameWithoutLanguage) = sam
document-format (mimeMediaType) = application/octet-stream
copies (integer) = 1
print-color-mode (keyword) = monochrome
Print file using Print-Job [PASS]
RECEIVED: 193 bytes in response
status-code = successful-ok (successful-ok)
attributes-charset (charset) = utf-8
attributes-natural-language (naturalLanguage) = en
job-uri (uri) = ipp://127.0.0.1:8080/jobs/2
job-id (integer) = 2
job-state (enum) = pending
job-state-message (textWithoutLanguage) =
job-state-reasons (keyword) = none
Get-Job-Attributes:
attributes-charset (charset) = utf-8
attributes-natural-language (naturalLanguage) = en
printer-uri (uri) = ipp://127.0.0.1:8080/printers/Canon_MG5700_series
job-id (integer) = 2
requesting-user-name (nameWithoutLanguage) = sam
Wait for job to complete... [0001]
job-state (enum) = processing
job-state-reasons (keyword) = job-printing
Wait for job to complete... [0002]
job-state (enum) = processing
job-state-reasons (keyword) = job-printing
Wait for job to complete... [0003]
job-state (enum) = processing
job-state-reasons (keyword) = job-printing
Wait for job to complete... [0004]
job-state (enum) = processing
job-state-reasons (keyword) = job-printing
Wait for job to complete... [0005]
job-state (enum) = processing
job-state-reasons (keyword) = job-printing
Wait for job to complete... [PASS]
RECEIVED: 1224 bytes in response
status-code = successful-ok (successful-ok)
attributes-charset (charset) = utf-8
attributes-natural-language (naturalLanguage) = en
number-of-documents (integer) = 1
job-media-progress (integer) = 0
job-more-info (uri) = http://127.0.0.1:8080/jobs/2
job-preserved (boolean) = true
job-printer-up-time (integer) = 1639669548
job-printer-uri (uri) = ipp://127.0.0.1:8080/printers/Canon_MG5700_series
job-uri (uri) = ipp://127.0.0.1:8080/jobs/2
printer-uri (uri) = ipp://127.0.0.1:8080/printers/Canon_MG5700_series
job-originating-user-name (nameWithoutLanguage) = sam
document-format (mimeMediaType) = application/pdf
copies (integer) = 1
print-color-mode (keyword) = monochrome
document-format-supplied (mimeMediaType) = application/octet-stream
document-format-detected (mimeMediaType) = application/pdf
job-priority (integer) = 50
job-name (nameWithoutLanguage) = Untitled
job-uuid (uri) = urn:uuid:a7390322-eefd-37d8-543b-fd2637889b65
job-originating-host-name (nameWithoutLanguage) = 172.17.0.1
date-time-at-completed (dateTime) = 2021-12-16T15:45:44Z
date-time-at-creation (dateTime) = 2021-12-16T15:45:23Z
date-time-at-processing (dateTime) = 2021-12-16T15:45:23Z
time-at-completed (integer) = 1639669544
time-at-creation (integer) = 1639669523
time-at-processing (integer) = 1639669523
job-id (integer) = 2
job-state (enum) = completed
job-state-reasons (keyword) = processing-to-stop-point
job-impressions-completed (integer) = 1
job-media-sheets-completed (integer) = 1
job-k-octets (integer) = 97
job-hold-until (keyword) = no-hold
job-sheets (1setOf nameWithoutLanguage) = none,none
job-printer-state-message (textWithoutLanguage) =
job-printer-state-reasons (keyword) = none
Summary: 2 tests, 2 passed, 0 failed, 0 skipped
Score: 100%