HPInc / jipp

A Java-compatible implementation of IPP
MIT License
144 stars 41 forks source link

overrides appears to be ignored #139

Open andygarratt opened 1 year ago

andygarratt commented 1 year ago

Hi,

We are trying to apply overrides in a print job, for example to use a different media for the first page or to apply sides to the first page, we are able to add the command but it appears ignored, the only difference between what we are doing and what PWG suggest is we are using job-attributes and not job-template

https://ftp.pwg.org/pub/pwg/candidates/cs-ipppageoverride10-20031031-5100.6.pdf

Has anyone had success with this and is job-template supported by jipp?

Get-Attributes confirms the device supports overrides and sides within overrides.

andygarratt commented 1 year ago

Here is an example of what we are sending to have the first page simplex

(v=0x200, c=Print-Job(2), r=0x1) {
operation-attributes {
   attributes-charset = utf-8,
   attributes-natural-language = en-us,
   printer-uri = ipp://192.168.0.161:631/ipp/print,
   requesting-user-name = "Cirros-C4-J13165" (name),
   document-format = application/pdf },
job-attributes {
   copies = 1,
   print-color-mode = color,
   sides = two-sided-long-edge,
   print-scaling = none,
   media-col = 
   {
     media-size = { x-dimension = 21000, y-dimension = 29700 },
     media-source = auto,
     media-type = auto },
   finishings = [ punch(3), staple(3) ],
   multiple-document-handling = separate-documents-collated-copies,
   overrides = { pages = 1..1, sides = one-sided } } }
andygarratt commented 1 year ago

This is the example from PWG

Print-Job
job template attributes group
media: letter
overrides: {
pages: 1:1
media: letterhead }
end-of-attributes
 Document A 
paaw2023 commented 4 months ago

I can confirm, Overrides ignore everything else besides the three documented members (document-copies, document-numbers, pages). Looks like genTypes.py is ignoring the definition "" of https://www.pwg.org/ipp/ipp-registrations.xml. I was able to workaround it by providing an Implementation of AttributeCollection:

public class SimpleAttributeCollection implements AttributeCollection {
    private final List<Attribute<?>> attributes;

    public SimpleAttributeCollection(List<Attribute<?>> attributes) {
        this.attributes = attributes;
    }

    @NonNull
    @Override
    public List<Attribute<?>> getAttributes() {
        return attributes;
    }

    @Override
    public void print(@NonNull PrettyPrinter printer) {
        printer.open(PrettyPrinter.OBJECT);
        printer.addAll(attributes);
        printer.close();
    }
}

and then adding the Override as an UnknownAttribute packed with above class:

new UnknownAttribute(overrides.getName(),
    new SimpleAttributeCollection(List.of(
        new UnknownAttribute(Types.pages.getName(), new IntRange(1, 1)),
        mediaCol.of(MediaCol.Companion.convert(List.of(MediaCol.mediaSource.of(MediaSource.tray4))))
)));