The sample code attached prints a text file 'sample.txt' which needs approximately 3 pages to print its data. A 'PageRanges' attribute is added to the HashPrintRequestAttribute to print only the second page. Both the isAttributeCategorySupported() and isAttributeValueSupported() method of PrintService are called to verify, before the attribute is passed on to the DocPrintJob.
The testcase when run still prints out all the 3 pages, when only one was expected.
Source File: PageRangesTest.java
Resource File: sample.txt