I have found the piece of the code in which the new window is launched, but I don't know how to modify it to prevent this:
$url1 = new moodle_url('/mod/book/print.php', array('id'=>$params['id']));
$url2 = new moodle_url('/mod/book/print.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid']));
if ($CFG->version > 2011020900) {
$action = new action_link($url1, get_string('printbook', 'book'), new popup_action('click', $url1));
$booknode->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_book', '', 'mod_book', array('class'=>'icon')));
$action = new action_link($url2, get_string('printchapter', 'book'), new popup_action('click', $url2));
$booknode->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_chapter', '', 'mod_book', array('class'=>'icon')));
} else {
$booknode->add(get_string('printbook', 'mod_book'), $url1, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_book', '', 'mod_book', array('class'=>'icon')));
$booknode->add(get_string('printchapter', 'mod_book'), $url2, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_chapter', '', 'mod_book', array('class'=>'icon')));
}
}