Posted by Steve on 10/12/07 11:57
> Is it possible (and if it is how?) to have php display the details of a
> word/excel/pdf document's properties/metadata?
You can do this via PHPs COM support, but only if you are hosted on
Windows with MS Office installed.
// for MSExcel use:
$objOfficeApp = new COM("excel.application") or die("unable to
instantiate MSExcel");
// for MSWord use:
//$objOfficeApp = new COM("word.application") or die("unable to
instantiate MSWord");
$objOfficeApp->Workbooks->Open( "c:\\temp\\test.xls" );
//$objOfficeApp->Documents->Open( "c:\\temp\\test.doc" );
$objDocProps =
$objOfficeApp->ActiveWorkBook->BuiltInDocumentProperties();
//$objDocProps =
$objOfficeApp->ActiveDocument->BuiltInDocumentProperties();
$count = $objDocProps->count();
while( $objDocProp = $objDocProps->Next() )
{
if( $objDocProp->Name() == 'Title' )
{
print 'Title: ' . $objDocProp->Value() . "\n";
break;
}
}
// *** IMPORTANT: release all resources correctly to avoid memory
leaks...
unset($objDocProp);
unset($objDocProps);
$objOfficeApp->ActiveWorkBook->Close();
//$objOfficeApp->ActiveDocument->Close();
$objOfficeApp->Quit();
unset($objOfficeApp);
---
Steve
Navigation:
[Reply to this message]
|