473,218 Members | 1,665 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,218 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 3064
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.