HPInc / jipp

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

How to choose tray of the printer? #119

Closed artem24630 closed 3 months ago

artem24630 commented 2 years ago

I need to print using the second tray if the first is empty, and printer can do this itself but not it doesn't (maybe I don't write some params to ipp request?). And I tried to choose a tray by writing putOperationAttributes(MediaCol.mediaSource.of("tray-2")) but it doesn't work. How to cope with it?

teemoo7 commented 2 years ago

Hello, Did you try to set this attribute to the job instead of the operation?

Example:

MediaCol mediaCollection = new MediaCol();
        mediaCollection.setMediaSource(new KeywordOrName(MediaSource.bottom));

IppPacket printRequest = IppPacket.printJob(uri)
    .putOperationAttributes(documentFormat.of("application/pdf"), pageRanges.of(new IntRange(1, 1)))
    .putJobAttributes(mediaCol.of(mediaCollection)).build();

I think it worked for me. Cheers