Chrome.Printing throws ticket error

105 views
Skip to first unread message

Dipti Kothari

unread,
Aug 24, 2022, 12:35:16 PM8/24/22
to Chromium Extensions
Hey

I am trying to implement an extension which does silent printing using chrome.printing API with manifest v3. The PrintJob type needs a CJT ticket which throws an Invalid Ticket error in console. 
Here's how my ticket looks like (which I got from https://developers.google.com/cloud-print/docs/cdd#cjt
ticket:{
                     "version": "1.0",
                     "print": {
                         "vendor_ticket_item": [],
                         "color": {"type": "STANDARD_MONOCHROME"},
                         "copies": {"copies": 1}
                     }
                },
Can you suggest the right format to get these ticket values.

Best
Dipti 

Nathan Muggli

unread,
May 23, 2023, 11:21:09 AM5/23/23
to Chromium Extensions, Dipti Kothari
Hi Dipti - 

Just seeing this - but hopefully it will help someone else searching for this.  There are some additional required fields for the ticket - updates to documentation are coming soon.  You might try something like this:

var ticket = {
    version: '1.0',
    print: {
      color: {type: 'STANDARD_MONOCHROME'},
      duplex: {type: 'NO_DUPLEX'},
      page_orientation: {type: 'PORTRAIT'},
      copies: {copies: 1},
      dpi: {horizontal_dpi: dpix, vertical_dpi: dpiy},
      media_size: {
        width_microns: width_microns,
        height_microns: height_microns,
        vendor_id: vendor_id
      },
      collate: {collate: false}
    }

With the appropriate dpi, width/height_microns, and vendor_id values (for example, info returned from getPrinterInfo function).

Thanks.
Nathan
Reply all
Reply to author
Forward
0 new messages