<?php
//
// PDF文書からJPEG画像へ変換
//
if (is_uploaded_file($_FILES['pdffile']['tmp_name'])) {
$pdffile = "../temp/".basename($_FILES['pdffile']['tmp_name']).".pdf";
move_uploaded_file($_FILES['pdffile']['tmp_name'], $pdffile);
$imgfile = "../temp/".basename($_FILES['pdffile']['tmp_name']).".jpg";
$command = 'convert '.$pdffile.'[0] -density 192 -resize 640\> '.$imgfile;
exec($command, $output, $return_var);
if ($return_var==0)
unlink($pdffile);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PDFからJPEGへ変換</title>
<style type="text/css">
* { margin: 0; padding: 0;}
</style>
</head>
<body>
<h3>PDFからJPEGへ変換</h3>
<div>
<img src="<?php print $imgfile; ?>" alt="<?php print $_FILES['pdffile']['name']; ?>" border="1"><br>
<code>
<?php
print $command."<br>\n";
if ($return_var) {
print implode("<br>\n", $output);
}
?>
</code>
</div>
<a href="sample.html">戻る</a>
</body>
</html>