user2970721
user2970721

Reputation: 146

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
    }
  }
 }
};

Upvotes: 3

Views: 515

Answers (2)

AhammadaliPK
AhammadaliPK

Reputation: 3548

I recommend you to use this way

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

Upvotes: 1

Jacob Marble
Jacob Marble

Reputation: 30242

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
    }
  ]
}

Upvotes: 1

Related Questions