Search code examples
pythonpython-3.xgoogle-cloud-print

How to programmatically get list of trays of a Google Cloud Print enabled printer in Python in a manufacturer independant way?


I am building a software where there is a requirement to submit a print to a Google Cloud Enabled printer to a particular tray.

Right now the approach I have taken is to use a Google service account and the submit the print to the printer using printer_id. I used a library called 'ezprinting' for the same.

I am able to submit print using printer id using the approach above. There is also a function in 'ezprinting' to get printer attributes that shows the details of printer including trays. But the problem is that the attributes are shown in different format for different printers.The structure is somewhat different and also the key corresponding to the tray list is different for different printers.

I was wondering if there is a way to list the trays of a printer in a printer/manufacture independant way?


Solution

  • Google Cloud Compatible printers are of gcpVersion 1.0 and gcpVersion 2.0.

    gcpVersion 1.0 is not promised to have any particular structure, though it is expected to have CDD version 1.0.

    gcpVersion 2.0 follows CDD version 1.0.

    Reference to CDD structure

    The list of trays will be available in key 'input_tray_unit' in the case of gcpVersion 2.0 printers.

    For printers with tray selection capability, the id required in CJT and the value of the tray will also be available in the key 'vendor_capabilities'.

    Reference to CJT

    From the printers that I had access to, I am afraid that there is no standard way for all the printers. I also came across printers that were gcpVersion 2.0, had trays listed in input_tray_unit but did not have the same listed in vendor_capability. From which, I understand that we cannot select a tray while creating a print job, though we can list the trays.