}
private void printPageable(final Doc doc,
final PrintRequestAttributeSet attributes)
throws PrintException {
final Pageable pageable = castDoc(doc, Pageable.class);
final PageFormat defaultFormat = getPageFormat(doc.getAttributes(),
attributes);
final long pdc = WinPrinterFactory.getPrinterDC(
service.printerName, service.getPrinterProps()
.getStructPtr());
final AttributeSet docAttrs = doc.getAttributes();
int pages = pageable.getNumberOfPages();
final PageRanges ranges = getAttribute(PageRanges.class, docAttrs,
attributes);
if (pages == Pageable.UNKNOWN_NUMBER_OF_PAGES) {
pages = Integer.MAX_VALUE;
}
try {
startJob(pdc, getDocName(pageable, docAttrs, attributes),
getDestinationPath(attributes));
for (int i = 0; i < pages; i++) {
if ((ranges != null) && !ranges.contains(i)) {
continue;
}
final Printable printable = pageable.getPrintable(i);
final PageFormat format = null;
if (printable == null) {
throw new PrintException("No such page: " + i); //$NON-NLS-1$
}