NYCPHP Meetup

NYPHP.org

[nycphp-talk] Stripping formatting from a word document

Ben Sgro (ProjectSkyLine) ben at projectskyline.com
Tue Jul 17 11:28:11 EDT 2007


Hello,

http://www.phpwordlib.motion-bg.com/ Looks good...but cost $..so doesn't 
look so good.
But has a demo.


Also, this code snippet:

> Hi
>
> I wish to read MS Word document content using PHP as like text file. Is
> anybody know any open source  PHP script for it. or any other way to do 
> it?

One easy way to grab the text from a word doc is to use the command line
program catdoc.

here are a couple of examples to get you started.

Dan

function catdoc_string($str)
{
	// requires catdoc

	// write to temp file
	$tmpfname = tempnam ('/tmp','doc');
	$handle = fopen($tmpfname,'w');
	fwrite($handle,$a);
	fclose($handle);

	// run catdoc
	$ret = shell_exec('catdoc -ab '.escapeshellarg($tmpfname) .' 2>&1');

	// remove temp file
	unlink($tmpfname);

	if (preg_match('/^sh: line 1: catdoc/i',$ret)) {
		return false;
	}

	return trim($ret);
}

function catdoc_file($fname)
{
	// requires catdoc

	// run catdoc
	$ret = shell_exec('catdoc -ab '.escapeshellarg($fname) .' 2>&1');

	if (preg_match('/^sh: line 1: catdoc/i',$ret)) {
		return false;
	}

	return trim($ret);
}- Ben

Ben Sgro, Chief Engineer
ProjectSkyLine - Defining New Horizons
+1 718.487.9368 (N.Y. Office)

Our company: www.projectskyline.com
Our products: www.project-contact.com

This e-mail is confidential information intended only for the use of the 
individual to whom it is addressed.
----- Original Message ----- 
From: "Jeff Loiselle" <jeff at newnewmedia.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Tuesday, July 17, 2007 11:24 AM
Subject: Re: [nycphp-talk] Stripping formatting from a word document


> http://us.php.net/strip_tags looks promising.
>
> On Jul 17, 2007, at 11:19 AM, Urb LeJeune wrote:
>
>> Is anyone aware of any PHP code that will strip formatting from a
>> Word document?
>>
>> Urb
>> Urb
>>
>> Dr. Urban A. LeJeune, President
>> E-Government.com
>> 800-204-9545
>>
>>
>> _______________________________________________
>> New York PHP Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> NYPHPCon 2006 Presentations Online
>> http://www.nyphpcon.com
>>
>> Show Your Participation in New York PHP
>> http://www.nyphp.org/show_participation.php
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php 




More information about the talk mailing list