[imp] Re: pdf mime type
G G Papazoglou
grp at med.uoc.gr
Tue Feb 11 13:40:51 PST 2003
> Did you add imp/lib/MIME/Viewer/pdf.php, defining the MIME_Viewer that
knows
> how to call pdftohtml?
No I didn't. Anyway I try to create a pdf.php using msword.php as a
template, but it
doesn't work (I get a blank window). Here it is:
<?php
class MIME_Viewer_pdf extends MIME_Viewer {
function render($params = null)
{
global $mime_drivers;
$tmp_pdf = Horde::getTempFile('pdf');
$tmp_output = Horde::getTempFile('pdf');
$tmp_dir = Horde::getTempDir();
$tmp_file = str_replace($tmp_dir . '/', '', $tmp_output);
$version = explode('.',
exec($mime_drivers['horde']['pdf']['location'] . ' --version'));
if (count($version) > 2 && ($version[0] > 0 || $version[1] >= 7)) {
$args = " --targetdir=$tmp_dir $tmp_pdf $tmp_file";
} else {
$args = " $tmp_pdf $tmp_output";
}
$fh = fopen($tmp_pdf, 'w');
fwrite($fh, $this->mime_part->getContents());
fclose($fh);
exec($mime_drivers['horde']['pdf']['location'] . $args);
if (!file_exists($tmp_output)) {
return _("Unable to translate this PDF document");
}
$out = fopen($tmp_output, 'r');
$data = '';
while (($rc = fgets($out, 8192))) {
$data .= $rc;
}
return $data;
}
function getType()
{
return 'text/html';
}
}
Is it something obvious I am doing wrong?
Greg
More information about the imp
mailing list