HPInc / jipp

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

Why sides attribute does not work? #87

Closed IvorHu closed 4 years ago

IvorHu commented 4 years ago

Hi there! I am trying to print two-sides papers with jipp 0.7.1. My pritner is HP LaserJet M203-M206 and it support two-sides printing. I get sides-supported=[one-sided, two-sided-short-edge, two-sided-long-edge] response from Operation.getPrinterAttributes. When I try to put sides attributes in Job Attributes Operation, I get unspported operations text in response. Here is my code:

         val printRequest = IppPacket.printJob(uri)
            .putOperationAttributes(
                attributesCharset.of("utf-8"),
                attributesNaturalLanguage.of("en"),
                requestingUserName.of("jprint"),
                documentFormat.of("application/pdf")
            )
            .putJobAttributes(
                sides.of(Sides.twoSidedLongEdge)
            )
            .setRequestId(1018)
            .build()
        try {
            val data =
                transport.sendData(uri, IppPacketData(printRequest, assets.open("2pages.pdf")))
            Log.i(TAG, "testPrint: $data")
        } catch (e: IOException) {
            e.printStackTrace()
        }

Here is the response:

MainActivity: testPrint: IppPacketData(packet=IppPacket(v=0x200, c=successful-ok-ignored-or-substituted-attributes(1), r=0x3fa) [AttributeGroup(operation-attributes, [attributes-charset="utf-8" (charset), attributes-natural-language="en" (naturalLanguage)]), AttributeGroup(unsupported-attributes, [sides=two-sided-long-edge]), AttributeGroup(job-attributes, [job-uri=ipp://192.168.1.101/ipp/print/0034, job-id=34, job-state=pending(3), job-state-reasons=none])], data=com.hp.jipp.encoding.IppInputStream@f3bf030)

The job is printed by one-sided. Two sided attribute is ignored according to the reponse. I am curious about it. Are the orders are correct in my code? I checked the #58 , but the orders may not my problem. Thanks in advance.

GladeDiviney commented 4 years ago

The request format looks correct to me. I don't know why the printer would reject this request if it supports the feature.

IvorHu commented 4 years ago

The request format looks correct to me. I don't know why the printer would reject this request if it supports the feature.

Thanks! Finally I ask config file from printer factory to change sides-default attribute to achieve my goal.