});
//Skip the prolog and to the first page
DSCComment pageOrTrailer = parser.nextDSCComment(DSCConstants.PAGE, gen);
if (pageOrTrailer == null) {
throw new DSCException("Page expected, but none found");
}
parser.setFilter(null); //Remove filter
//Process individual pages (and skip as necessary)
while (true) {
DSCCommentPage page = (DSCCommentPage)pageOrTrailer;
boolean validPage = (page.getPagePosition() >= from && page.getPagePosition() <= to);
if (validPage) {
page.setPagePosition(page.getPagePosition() - from + 1);
page.generate(gen);
pageCount++;
}
pageOrTrailer = DSCTools.nextPageOrTrailer(parser, (validPage ? gen : null));
if (pageOrTrailer == null) {
throw new DSCException("File is not DSC-compliant: Unexpected end of file");
} else if (!DSCConstants.PAGE.equals(pageOrTrailer.getName())) {
pageOrTrailer.generate(gen);
break;
}
}