HPInc / jipp

A Java-compatible implementation of IPP
MIT License
153 stars 42 forks source link

overrides appears to be ignored #139

Closed andygarratt closed 3 months 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 9 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))))
)));
HPNavjot commented 3 months ago

@andygarratt we have added a fix for overrides attributes in Release v0.7.16-beta1. Can you try reproducing the issue with library version v0.7.16-beta1

HPSudip commented 3 months ago

Fix present in v0.7.16. Hence closing.