\n"; if ($filetype == "pdf") { $filename = str_replace("\\", "\\\\", $filename); if (@file_exists($filename)) { $file = fopen($filename, "r"); # read file $regexAuthor = "/\/Author \((.*?)\)/"; $regexTitle = "/\/Title \((.*?)\)/"; $regexSubject = "/\/Subject \((.*?)\)/"; $regexKeywords = "/\/Keywords \((.*?)\)/"; $regexCreationDate = "/\/CreationDate \((.*?)\)/"; $regexModDate = "/\/ModDate \((.*?)\)/"; while (!feof($file)) { $line = fgets($file); if (!feof($file)) { if (preg_match($regexAuthor, $line, $m)) echo "Author = ".$m[1]."
"; if (preg_match($regexTitle, $line, $m)) echo "Title = ".$m[1]."
"; if (preg_match($regexSubject, $line, $m)) echo "Subject = ".$m[1]."
"; if (preg_match($regexKeywords, $line, $m)) echo "Keywords = ".$m[1]."
"; if (preg_match($regexCreationDate, $line, $m)) echo "Creation Date = ".makeDate($m[1])."
"; if (preg_match($regexModDate, $line, $m)) echo "Modification Date = ".makeDate($m[1])."
"; } } fclose($file); } else { echo "file ".$filename." does not exist!
"; } } else { // XLS, DOC, PPT $officetype = TRUE; // starting office switch ($filetype) { case "ppt": $office = new COM("powerpoint.application"); $office->Presentations->Open($filename, True,True,False); $document = $office->Presentations[1]; break; case "doc": $office = new COM("word.application"); $office->Documents->Open($filename); $document = $office->Documents[1]; break; case "xls": $office = new COM("excel.application"); $office->Workbooks->Open($filename); $document = $office->Workbooks[1]; break; default: echo "This filetype can't be handled by this script!"; $officetype = FALSE; } if ($officetype == TRUE) { echo "Display a single Buildin Property
\n"; echo "Author = ".$document->BuiltInDocumentProperties->Item("Author")->Value."
\n"; echo "Buildin properties
\n"; foreach ($document->BuiltInDocumentProperties as $myVar) { try { echo $myVar->Name." = ".$myVar->Value."
\n"; } catch (Exception $e) { // Do nothing ignore property we can't read } } echo "Custom properties
\n"; foreach ($document->CustomDocumentProperties as $myVar) { try { echo $myVar->Name." = ".$myVar->Value."
\n"; } catch (Exception $e) { // Do nothing ignore property we can't read } } // closing $office->Quit(); // free the object $office = null; unset($office); } } } else { echo 'Usage: '.$_SERVER['PHP_SELF'].'?filename=filename.ext'; } ?>