コード例 #1
0
include_once 'pdfclass.php';
session_write_close();
// Sanitize PDF filename.
$file = '';
if (!empty($_REQUEST['file'])) {
    $file = preg_replace('/[^a-zA-z0-9\\_\\.pdf]/', '', $_REQUEST['file']);
} else {
    sendError("No PDF provided.");
}
$pdfHandler = new PDFViewer($file);
if (!empty($_GET['extractimage']) && !empty($_GET['image']) && !empty($_GET['x']) && !empty($_GET['y']) && !empty($_GET['width']) && !empty($_GET['height'])) {
    // Extract image from a pdf page image.
    $pdfHandler->extractImage($_GET['image'], $_GET['x'], $_GET['y'], $_GET['width'], $_GET['height']);
} elseif (!empty($_GET['renderpdf']) && !empty($_GET['page'])) {
    // Create page image.
    $pdfHandler->createPageImage($_GET['page']);
} elseif (isset($_GET['renderthumbs']) && !empty($_GET['from'])) {
    // Create thumbs.
    $pdfHandler->createPageThumbs($_GET['from']);
} elseif (isset($_GET['renderbookmarks'])) {
    // Extract bookmarks.
    echo $pdfHandler->extractBookmarks();
} elseif (isset($_GET['rendertext'])) {
    // Extract text into database.
    $pdfHandler->extractXMLText();
} elseif (isset($_GET['gettextlayer']) && !empty($_GET['from'])) {
    // Get text from the database.
    echo $pdfHandler->getTextLayer($_GET['from']);
} elseif (isset($_GET['searchtextlayer'])) {
    if (empty($_GET['search_term'])) {
        sendError('No search term provided');
コード例 #2
0
ファイル: icon.php プロジェクト: jamesscottbrown/i-librarian
header("Cache-Control: private");
header('Last-Modified: ' . gmdate(DATE_RFC1123, filemtime($pdf_path . DIRECTORY_SEPARATOR . $file)));
// Content type
header('Content-Type: image/jpeg');
header("Content-Disposition: inline");
// Output from cache
if (is_readable($icon) && filemtime($pdf_path . DIRECTORY_SEPARATOR . $file) < filemtime($icon)) {
    ob_clean();
    flush();
    readfile($icon);
    die;
}
// Make big image if not found
if (!is_readable($image) || filemtime($image) < filemtime($pdf_path . DIRECTORY_SEPARATOR . $file)) {
    $pdfHandler = new PDFViewer($file);
    $pdfHandler->createPageImage(1);
}
// Icon dimensions
$new_width = 720;
$new_height = 480;
if (!is_readable($image)) {
    // Error! Ghostscript DOES NOT WORK
    $image_p = imagecreate($new_width, $new_height);
    $background_color = imagecolorallocate($image_p, 255, 255, 255);
    $text_color = imagecolorallocate($image_p, 255, 0, 0);
    imagestring($image_p, 3, 20, 20, "Error! Program Ghostscript not functional.", $text_color);
} else {
    // Resample
    list($width, $height) = getimagesize($image);
    $image_p = imagecreatetruecolor($new_width, $new_height);
    $image = imagecreatefromjpeg($image);