473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Obtaining file attribute - title, PDF, Word, Excel

Hello -

I'm trying to write something that will traverse the directory
structure of my web server directory and pull some particular
information on particular file types to create a listing of what all is
where.

For PDF files I want to find the title. I've been looking through
php.net and the ClibPDF Functions, but I'm still not clear on how to
find the title of an existing pdf document.

I also want to find the titles of Word and Excel documents.

I already have the code to traverse the directory structure.
Thanks in advance for information!

Jennlee2

Jul 17 '05 #1
3 3066
I use this to find file types.

$pdf_filenames = array();
$potential_pdf = explode(".pdf", $fileName);
if (count($potential_pdf) == 2) {
$pdf_filenames[] = $potential_pdf[0];
}

There are dozens of ways to get the file name. You could also use
regex functions as well.

Jul 17 '05 #2

Um, OP wants the /document titles/ not the filenames.

Can't help with PDFs, but for MS Excel and MS Word use the COM
interface...

<?php

$objOfficeApp = new COM("word.application")
or die("unable to instantiate MSWord");

....OR...

$objOfficeApp = new COM("excel.application")
or die("unable to instantiate MSExcel");

$objOfficeApp->Documents->Open( "c:\\temp\\test.doc" );
....OR...
$objOfficeApp->Workbooks->Open( "c:\\temp\\test.xls" );

$objDocProps =
$objOfficeApp->ActiveDocument->BuiltInDocumentProperties();
....OR...
$objDocProps =
$objOfficeApp->ActiveWorkBook->BuiltInDocumentProperties();

$count = $objDocProps->count();

while( $objDocProp = $objDocProps->Next() )
{
if( $objDocProp->Name() == 'Title' )
{
print 'Title: ' . $objDocProp->Value() . "\n";
break;
}
}

unset($objDocProp);
unset($objDocProps);

$objOfficeApp->ActiveDocument->Close();
....OR...
$objOfficeApp->ActiveWorkBook->Close();
$objOfficeApp->Quit();
unset($objOfficeApp);

?>

---
Steve

Jul 17 '05 #3
Thanks, Steve -

Will try this - looks like what I am looking for.

Jennlee2
Steve wrote:
Um, OP wants the /document titles/ not the filenames.

Can't help with PDFs, but for MS Excel and MS Word use the COM
interface...

<?php

$objOfficeApp = new COM("word.application")
or die("unable to instantiate MSWord");

...OR...

$objOfficeApp = new COM("excel.application")
or die("unable to instantiate MSExcel");

$objOfficeApp->Documents->Open( "c:\\temp\\test.doc" );
...OR...
$objOfficeApp->Workbooks->Open( "c:\\temp\\test.xls" );

$objDocProps =
$objOfficeApp->ActiveDocument->BuiltInDocumentProperties();
...OR...
$objDocProps =
$objOfficeApp->ActiveWorkBook->BuiltInDocumentProperties();

$count = $objDocProps->count();

while( $objDocProp = $objDocProps->Next() )
{
if( $objDocProp->Name() == 'Title' )
{
print 'Title: ' . $objDocProp->Value() . "\n";
break;
}
}

unset($objDocProp);
unset($objDocProps);

$objOfficeApp->ActiveDocument->Close();
...OR...
$objOfficeApp->ActiveWorkBook->Close();
$objOfficeApp->Quit();
unset($objOfficeApp);

?>

---
Steve


Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jan Nordgreen | last post by:
In my main.php I have this doc declaration at the top: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Later in main.php I use...
3
by: John | last post by:
Hello, I need to know which programs are opn on another machine in my network, these programs are opened from a shared drive on the server. How can I do this ? I've already dowloaded a sample...
1
by: Desi | last post by:
XML gurus, I need help in converting my feedreader subscription XML file to an OPML file. I have no idea how to do that. Thanks in advance.
1
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
2
by: Robert | last post by:
I have the XML file which has a structure similar to one I pasted at the end of this post. As you can see many elements are using different id attributes. For example element Window uses WinID...
3
by: herman404 | last post by:
Hi everyone, I have data coming to me in the form of Word and Excel files, and I need to place this data into a SQL Server database. The Word file will be coming in text which is similiar to an...
11
by: sandeepkedlaya | last post by:
Hello, I need to copy images from a folder and copy to a word document. I have done as follows.. but It copies only last image. Can any one of you help me in this.. Private Sub Page_Load(ByVal...
3
by: ArmageddonAsh | last post by:
I'm trying to make an application that will allow the user to enter data into a flexgrid (that's done) and then save the data from that flexgrid into a CSV file but even though the file is made none...
6
by: slinky | last post by:
I found the following code to transfer datagrid data to an Excel file. Is this written in C#?... I'm a vb.netter. I'm just not sure where to place the code to experiment on it. Should I place it in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.