ByteBuffer buf = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
pdfFile = new PDFFile(buf);
pageStart = 0;
pageEnd = pdfFile.getNumPages();
OutlineNode on = pdfFile.getOutline();
if (on != null) {
for (int i = 0; i < on.getChildCount(); i++) {
OutlineNode child = (OutlineNode) on.getChildAt(i);
GoToAction act = (GoToAction) child.getAction();
//Find the beginning of the chapter selected,
//then take the page start and page end number
if (child.toString().toLowerCase().startsWith(marker.getChapterPrefix().toLowerCase())) {
currentOutline = child;
pageStart = pdfFile.getPageNumber(act.getDestination()
.getPage());
if (i + 1 < on.getChildCount()) {
OutlineNode childAfter = (OutlineNode) on
.getChildAt(i + 1);
GoToAction actAfter = (GoToAction) childAfter
.getAction();
pageEnd = pdfFile.getPageNumber(actAfter
.getDestination().getPage());
}// else if child is the last one, pageEnd is already set.
break;