javascriptgoogle-cloud-print

page_range in Google Cloud Print Ticket


I'm trying to write a program that prints only the first page of a document using Google Cloud Print. I have gotten all parameters to work except for page_range and cannot decipher the Developer Guide on this matter. Is anyone able to tell me what's wrong with the format that I am using for page_range? I am using a JavaScript List

var ticket = {
 version: "1.0",
 print: {
  color: {
    type: "STANDARD_COLOR",
    vendor_id: "Color"
  },
  duplex: {
    type: "NO_DUPLEX"
  },
  copies: {copies: 1},
  media_size: {
     width_microns: 27940,
     height_microns:60960
  },
  page_orientation: {
    type: "LANDSCAPE"  
  },
   margins: {
     top_microns:0,
     bottom_microns:0,
     left_microns:0,
     right_microns:0
  },
  page_range: {
    interval: {
      start:1,
      end:1
    }
  }
 }
};

Solution

  • page_range contains a repeated field named interval. It's repeated so that you can request multiple ranges:

    // Ticket item indicating what pages to use.
    message PageRangeTicketItem {
      repeated PageRange.Interval interval = 1;
    }
    

    PageRange.Interval looks like this:

    // Interval of pages in the document to print.
    message Interval {
      // Beginning of the interval (inclusive) (required).
      optional int32 start = 1;
    
      // End of the interval (inclusive). If not set, then the interval will
      // include all available pages after start.
      optional int32 end = 2;
    }
    

    So try this to print pages 1 and 6-7:

    page_range: {
      interval: [
        {
          start: 1,
          end: 1
        },
        {
          start: 6,
          end: 7
        }
      ]
    }