Beispiel #1
0
    protected function processFileToImageCache($filePath, $cacheLocation)
    {
        if (!is_dir($cacheLocation)) {
            mkdir($cacheLocation);
        }
        $imagick = new \Imagick();
        $imagick->setResolution(150, 150);
        $imagick->readImage($filePath);
        $imagick->writeImages($cacheLocation . '/rendered.jpg', true);
    }
}
ob_start();
$pdfViewer = new PDFViewer();
// NO ACTION means to just show the list
if (!isset($_GET['action'])) {
    $PDFs = $pdfViewer->getPDFList();
    if (empty($PDFs)) {
        echo '<p>There are no PDFs available.</p>';
    } else {
        echo '<p>Choose a file:</p>';
        echo '<ul>';
        foreach ($PDFs as $pdf) {
            $filename = basename($pdf);
            echo "<li><a href='?action=view&file={$filename}'>{$filename}</a></li>";
        }
        echo '</ul>';
    }
} else {
    if ($_GET['action'] == 'view' && !empty($_GET['file'])) {
        $images = $pdfViewer->getImageList($_GET['file']);
        echo '<p>Viewing file ' . htmlentities($_GET['file']) . '</p>';