/*
Copyright(c)2008 Internet Archive. Software license AGPL version 3.
This file is part of BookReader.
BookReader is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BookReader is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with BookReader. If not, see .
BookReaderPrint.php exists to get around the same-origin policy that prevents
us from calling print() on an iframe that comes from a cluster datanode.
*/
$id = $_REQUEST['id'];
$server = $_REQUEST['server'];
$zip = $_REQUEST['zip'];
$file = $_REQUEST['file'];
$format = $_REQUEST['format'];
//$imgAspect = $_REQUEST['aspect'];
$width = floatval($_REQUEST['width']);
$height = floatval($_REQUEST['height']);
$title = $_REQUEST['title'];
/* We assume that the print aspect ratio is somewhat close to US Letter in portrait orientation */
$paperAspect = 8.5/11;
// $$$ may want to adjust this if two page with foldout looks strange
$allowRotate = true;
// Returns (url, attrs)
function imageURL($paperAspect, $file, $format, $width, $height, $allowRotate) {
global $server, $id, $zip;
$rotate = "0";
$imgAspect = $width / $height;
if ('jp2' == $format && $allowRotate) {
// Rotation is possible
if ($imgAspect > $paperAspect && $imgAspect > 1) {
$rotate = "90";
$imgAspect = 1 / $imgAspect;
}
}
if ($imgAspect > $paperAspect) {
// wider than paper, fit width
$htmlAttrs = "width='95%'";
} else {
// taller than paper, fit height
$htmlAttrs = "height='95%'";
}
$queryParams = array(
'id' => $id, // global
'format' => $format,
'index' => $index,
'file' => $file,
'zip' => $zip, // global
'rotate' => $rotate,
'scale' => 1
);
$_server = htmlspecialchars($server);
return "";
}
echo "