Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Convert Word-to-Text On Linux


How can I read a Word document and convert it to text (just in memory
is fine) on a Linux machine where there is no Word installed?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Convert MS Word / Rtf / ... To Plain Text
i'm looking for standalone libraries that convert documents to plain text so i can let people edit the text in a textarea after uploading. One thing to notice is that i can not use COM because i can't configure the webserver.

Does anyone has interesting classes that are able to do this. I found a PHP class for ms word documents at http://obninsk.name/obninsk_doc/ but that doesn't work at all for my word documents.

PHP To WORD On Linux? COM Object..
Does anyone one if there is a way to generate a word-document with PHP on a Linux box? I've done this on my Win2000 machine with COM objects. But is there a way on a Linux box?

Html To Word Convert With Php
Html to word convert with php. Is there any one to help to convert a html php document to convert by doc(Word file).

Convert Word To HTML
How to convert MS Word 2003 file to HTML using php script?

Read File MS Word, Convert File Txt To MS WORD,
1. how can i read file and content from MS WORD file..
2. how i can create or convert to MS WORD file with php..

Can I Convert MySQL Db Records Into Microsoft Word Documents?
i found the solution to export
file from mysql db into *.csv. but is there anyway to convert the
contents into *.doc and save in my webserver and providing a link for
the end users to download the word file?

FYI, the database records are obtained by end users submitting the
forms themselve and i saved it in my db...

Get The Last Word From A Text File
i have a text file that's update all the time. i need to get the last word from it. how can i do that?

Convert Text
I have a text like this: "Thuyền Và Biển"
How to convert it to: "Thuyá»n VÃ* Biển"

Formatting Text In Word Document
I am building a web site that displays the contents from a MySQL database in a word file and saves it to disk. Problem is that I can create the file but I dont know how to format the text in the word document.

Finding A Key Word In A Text File
I would like to find a word stored in a text file.

Structure: I have one file named keyWords.txt that stores some key
words I'm interested in finding. In addition I also have a file named
textOrigin.txt in which I store the text to search in.
I would like my prog to check if a certain word appears in the text
and than to tell me what line it found it in (if it did...).

My problem is that the script can't find the words I'm looking for. I
took one word from the word list and put it into the text file to be
searched, for some reason this word is not found by the prog. I used
'enter' at the end of each line. The word being used is on line 3 in
the keyWords.txt file. I have some reason to belive that the reason
lie here:
if ($pos)
{
echo " line $i: $storeWord[$n]
";
}
I also tried it with if (!$pos === FALSE) {...} but nothing there
either...

the keyWords.txt file:
-------------------------------
Recording Site
Recording Type
INTRA
SUA
................

Echo To Text Box Only Returns First Word
I'm echoing values from a db to text boxes with php, but only the first words are returned. The db field is set to varchar(255). Can someone please tell me how to solve this small but annoying problem? By the way, I don't have any regular expressions or that kind of coding.

Extract Text From Word Documents
Is there a way to extract the text of a word document with php? And perhaps some of the formatting (like break lines, bold, italic,...)?

Insert Text, Ms Word Document
i've hit a wall regarding php and ms word. what i want is to open a
document containing bookmarks, insert text where the bookmarks are, and
save.

it's working, unless the bookmark is in the header part of the page (re
header/ footer). in that case i get an error saying the bookmark
wasn't found/ doesn't exist.

anyone got any tip on how to get into the header part of a word
document using php?

the following, simple code works when bookmark is in the main part of
document:

$empty = new VARIANT();
$word = new COM("word.application") or die ("some explanation");
$word->Documents->Open("C:PathDocument with bookmark.doc");
$word->Selection->GoTo(wdGoToBookmark, $empty, $empty, "bookmark");
$word->Selection->TypeText("text to be inserted");
$word->Documents[1]->SaveAs("C:Pathwith inserted text.doc");
$word->Quit();
$word = null;

How To Convert Any Text To Unicode?
How can I convert any text to unicode please help me

Convert Text To A Percent
Im making a useless little program that takes 2 peoples names and tests their love compatibility as a percentage. I dont want a random number generator because I want to make it so when you enter the same name twice you get the same result.

Any ideas how to put the to strings together to get a varying percentage. I have tried a few things. One i converted both the strings to md5 and then did similar_text() to compare... however the percentages were always low... I want a mixed result.

How To Convert Ascii To Text
I replace some user input with their ascii equivalent so they display
on the webpage properly:

$entry = preg_replace ( "/'+/" , '&#39' , $entry);
$entry = preg_replace ( "/,+/" , '&#44' , $entry);

I then need to email the data, however in email the ascii code is
displayed, not the text.

Is there an easier way to convert the ascii back to the text without
another preg_replace?

Full Text Search In PDF And Word Files ?
I need to perform full text searches on a batch of PDF and Word files.
What is the best way to go?

After some research, I'm thinking of extracting the plain text from the
files with "pdftotext" and "catdoc", hamonizing the various possible
encodings to UTF-8, storing the text in a MySQL database, and then
using the full text search capabilities of MySQL.
Do you think that would work well? I am told that the files are mostly
text and won't be longer than 30 pages.

Regular Expression To Underline A Given Word In A Text...
With the sentence :

"Bordeaux est au bord de l'eau"

How to do to underline, for instance, the word "eau" ? without underlining
the substring of "Bordeaux" ?
I don't know how to isolate the word...

My current code :

$text=eregi_replace("(".stripslashes($word_to_underline]).")","<b></b>",$
text);

but this underline "eau" in "Bordeaux" too and i don't want to !

Convert Php Data Into Text File?
I have a php file that gathers data from a specific website. I am then using that data (numbers) in a different application. The only problem is the html formatting. I just need the numbers, but I'm getting all the html tags with the data. Is there a way for me to have the php file output in to a seperate plain text file?

Convert Text From Database For HTML
I'm pulling text from a database (MySQL) and I'm using the nl2br () function to convert the line breaks

DESCRIPTION="<?php echo nl2br($row_rsttheJobResults['description']); ?>"

This creates the following example

"A new line will be created soon < 'br' >
and here it is."

However the website that receives this cannot accept the characters < and >
So I want to convert this "< br >" into this "&lt;p&gt;"

Could anybody help me add to the nl2br () function to convert the < br > tags?

* the spaces between the < and br are there because they won't show in the message otherwise

Search For A Specific Word Inside A Text File?
Basically what i'm trying to do is when a user inputs login/password information at a login page, I want PHP to search inside verify.txt and if it finds the login/password combination then allows the user to proceed. Is this possible? And if so, which functions would I use to get the job done?

Also, how can I save the login name so that it can be passed to/included in a url?

How Convert Http:// Text To Real Hyperlink?
I have some texts in MySQL databases. When I show this texts in webpages using PHP, I need to convert every ocurrence of

http://blablabla.com

to

<a href='http://blablabla.com'>http://blablabla.com</a>

, so my text will really became 'active'. The people who wrote the texts don't know HTML tags so I can't ask them to write explicity <a...> </a> commands. The problem is the same with text that contains the @ charactere, as

name@mailserver.com

. I have to change this to

<a href='mailto:name@mailserver.com'>name@mailserver.com</a>.

Please, I don't know how to use regular expression. I think It can make this replacemments very easy..

Convert Numerical To Text For Check Writing
Does anyone know of/have an open source class that will compose the text
version of a dollar amount? For instance, convert $525.62 to "Five hundred
twenty five and 62/100 dollars".

I'm trying to write a quick accounts payable app and I really do not want
to have to write this part from scratch!!

What Is The Preg For Capitals In A Word To Be Replaced By That Word Preceded By A Space
what is the preg for capitals in a word to be replaced by that word
preceded by a space?

i need to be able to do this in preg:

thisWord := this Word
AnotherExample := Another Example

strings with capitals sorrounded by other chars need to have a space
inserted before the capital.

Quickly Adding Text To A Mysql Text Field That Is NOT Empty
Is there a way to insert text into a mysql text field that already has
text into it; without having first to extract the existing data and
append the new text to that string variable and then insert the new
string.

Basically i'm looking for a way to do it with a single query not 2 (one
being a select to gather existing data).

Gaining Access To How MySql Parses Text For Full Text
I want to gain access to the function or process MySql uses to parse words and phrases for Full Text searching. Here is an example.

If the user inputs...

Milan in history

MySql will search for milan, history, and milan history. Is there a way to extract just the combination of terms MySql uses to search the db without the stop words? Stop words are automatically eliminated from the search request unless the user encloses a phrase in quotes.

What I am trying to do is develop a script to highlight found search terms and phrases. I can explode a phrase into single words but if I do that the stop words would be included in the array. If there is some way of getting into the parsed words or phrases MySql Full Text actually uses to search, I can use each of those combinations as a keyword in my highlighting script.

This request is about searching for the code or any code related to the questions involved.

Text Area Not Accepting Large Amounts Of Text
I have a form where teachers enter homework assignments and they are then stored in a MYSQL database and retrieved elsewhere.

I have been using "get" with the form. The code is simple:

<textarea name="array[assignment]" cols="60" rows="10" id="array[assignment]"></textarea>

It does allow post of 100 words, etc. Stuff that teachers normally submit.

What's happening is that it won't allow very large posts (over 300 words maybe? ) Not sure what the cut off is. When you press submit it won't go, or there is an error where it won't submit.

Is there a limit for text fields? Since the fields scroll, I didn't think that having only 60 rows was any type of real limit, I though you could put in as much as needed. But then all of it ends up in the address bar, so there must be a limit of some sort.

Imagettftext() Gives Grainy Text When Writing Aliased Text
I'm using a bundled version of GD: 2.0.23 compatible. When using the
function imagettftext() with a negative color to get a aliased text,
the text gets grainy. What could be wrong? I've tried several ttf
fonts, with the same result.

Read And Display Japanese Text From Text File
I posted a question regarding reading japanese
text from a text file.

Well, since I solved the problem, I thought I'd post my solution for
the benefit of other people with the same problem.

The plan was to make a script to read and display japanese text. I
will use it for making a japanese proverb script and for a japanese
language study script.

Method :

I wrote a simple kanji text file (saved with UTF-8 encoding)
I wrote a simple PHP script to display the file contents (saved with
UTF-8
encoding)
I specified the content-type header for the HTML page :
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

*** All files have the same encoding. ***

UTF-8 supports japanese characters.

and it works!

this is my PHP (and HTML) script :

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PHP : Japanese Text File Read : Exercise 1</title>
</head>
<body>

<?php

$filename="japanese.txt";
//open file
$fp = fopen($filename,'r');

//loop through each line in the file
while($line=fgets($fp))
{
//output current text file line
print $line."<br>";
}
//close file handle
fclose($fp);

?>

</body>
</html>

I know it's a very simple script, for testing purposes only. It
displays the contents of the japanese text file line by line.

The key was to save all files in the same encoding (I used UTF-8) and
to specify the encoding / charset in the HTML header (<meta
http-equiv="Content-Type" content="text/html; charset=utf-8">)

Php & Ms Word
I want to display a .doc file to an html page, using PHP. The doc file is located in a MySQL db. It will be used for displaying some announcements through the main web page.

COM And Ms Word
I've read "PHP and COM" by Harish Kamath and I've got a problem just at the beginning.
I'm not able to create an instance of the Word application:

"$word = new COM("word.application") or die("Unable to instantiate application object")".
It doesn't print the die message, it is simply always "sending request to 127.0.0.1 ..."
Is it a problem of "php.ini" settings? I'm using PHP4.0.6 on Windows2000 (Office2000).

COM & Word
I am trying to print a document after merging some data into it using PHP
COM and it seems to be very tempremental and doesn't work at all over
network printers. When I say tempremental, if it works on a machine it
works, no question, but if it doesn't it just goes nowhere and doesn't say
anything at all.

Defintely works on Windows XP Pro, but again tempremental, once it wasn't
working and I did everything possible, all office updates etc. but gave up
and just re-installed windows and it worked fine.

Windows 2000, i think i've had it working

Windows 2000 Server, not working.

All using Office 2000, but even tried the Office 2003 on Windows 2000 Server
and nothing at all.. :( It seems very badly documented.

The code I use to print: (a simplified just to do the task)

<?

$empty = new VARIANT();
com_load_typelib('Word.Application');
$word = new COM('word.application') or die('Unable to load Word');
print "Loaded Word, version {$word->Version}
<br/>";

$word->Documents->Open("c:/templates/Options.doc");

$output="";
$word->ActiveDocument->PrintOut(0,0,0,$output);

?>

Is there any known good resources for doing this? Can anyone shed any light
on this?!

PHP, COM And WORD
I'm having some difficulties with PHP and COM (don't worry I can connect to MS WORD and do stuff). Having desperately Google'd it for 6 hours, here is my lays my last hope.There are two things (Actually three) :

1) a) I want to be able to use styles in WORD to format my created word document. I looked at the list but I just can't seem to find the right command.

b) If there is no such use, I want to learn how to create my own styles (the company I'm developing the project has customized heading and subheading styles). So I can mimic Word's settings.

2)I'm having encoding problems. My mysql dbase and browser are working on UTF8. The problem is when I create a word document and dump data on it, the special characters just go crazy. I tried $word->Documents[1]->TextEncoding=20905; but it doesn't seem to work. Maybe I messed with the syntax but code generates no errors. Just crap letters on special characters.

PHP And Word COM
I've just starting to use the COM library with Word 97 and I can create new documents based on the example given in the php manual. I'm running PHP 4.0.4 using OmniHTTPd on a Windows 98 machine - the final version will run from a NT 4.0 server.

My problem - I want to do a search an replace to tailor a Word template. The code I have been trying at the foot of this message - basically, all I am doing is converting working VBA into PHP syntax. But PHP crashes as soon as it hits find->execute(). Code:

MS Word To .gif
I need to create preview-images from MS Word documents using PHP. Any Idea
how I could accomplish this?

,php To .htm To Ms Word
I've written a (single-page) script that works like this;

If no values are posted to it, the script creates a form page for a
user to fill in and 'submit'.

If values are posted to it (i.e. the user filled in the form), the
script renders a page of html with the user-supplied values.

Straightforward stuff, however, if values are posted I'd like the
rendered page to open in MS word for further editing, instead of the
users default browser.

What steps can I take to acheve this?

PHP/XML To Word
We use an intranet for the generation of quotes for customers. Once a salesman has selected the quote they can then open it as a word document to edit the details. The word document comes with a customized header for each geographical region.

Recently one of the offices moved so we went to the webserver and updated all of the gif's with the new address which will appear before the page is converted to word. Once its converted to word however, the old address appears. I'm at a loss.

Append Text At End Of Existing Text On Same Line
I'm working on a part of my web site that uploads images, then writes the name of the image to a text file. The upload part works fine. The part that writes the name of the image to the text file works fine.

What I'm trying to do is, after all the files have been uploaded and all of the image names have been written to the WriteTo.txt file, append a written description of the picture at the end of the picture name. In other words, after a user uploads their pictures to the server I want to direct them to a page where they can label each of the pictures using a form. PHP Code:

Adding Text To Text Window With A Button
I have made an admin section of a site, What i want to do i have buttons under that have "BOLD" "center" and when clicked it adds <b></b> tags to the text area etc etc..

if the text area was called "message"

how would i going about coding the images / buttons to add the code?

PHP - Using Mail() And Unicode Text - Text Gets Disturbed
I have the following problem. On a website there's a (simple) feedback
form. This is used also by Polish visitors who (of course) type Polish
text using special characters.

However, when I receive the text in my mailbox, all special characters
have been turned into mess......

For example: "wspólprace" is turned into "współprace".

It seems PHP is handling the Unicode-8 strings quite well (when I
'echo' the strings on the site, I see the text correctly), until the
point that it is send by using mail().

Is this a server configuration issue? Or something else?

How can I get my text to remain in Unicode?

I have this problem both on my testserver (Apache 1.3.28, PHP 4.3.2 on
Windows XP) as on my providers server (Apache under Linux).

Remove Text Header In Text File
I have been having trouble removeing two header lines at the top of my txt file. You will see in my code the different things I have tried but with no luck. Below I posted my script and data. I am doing a few other things in my script as you will notice but this is the only thing I am having troble with. Code:

Parsing Text - Capture Text Between Two Tags
I want to have text in files, such as

{body}
{/body}

and then be able to open that file and grab all of the data inbetween those tags. I could open the file and go through it until I see the {body} tag and then store data until I reach {/body} but that is a bad way to do it.

Text Returned From DB Gets Cutoff When Placed In A Text Field
I have a string that contains an apostrophe or a quotation mark, stored in a DB. I can retrieve the data, and display it properly (for editing) in a textarea, but when I try to put the string in a text field, it get's cut off right before the questionable character.

For example:
$string_in_database = "John's car."

 -displays correctly here <textarea><?php print $string_in_database ?></textarea> and displays this - John's car.

 -gets cutoff here <input type='text' value=''<?php print $string_in_database ?>' /> and displays this -  John

I've tried adding slashes and stripping slashes and I just can't figure out what I need to do.

Keep Text In Text Boxes After Form Is Rewritten
I'm trying to make a form that does the following:

(1) the user answers a question by typing in a text box
(2) a response is then written below the form, saying whether the answer is right or wrong and, perhaps making a comment of some kind
(3) the user's answer remains visible in the original text box

I've managed to write some code that does the first two things, but despite many attempts and much searching for code examples, I've failed to find a way of getting the answer to reappear in the text box when the page is rewritten.

This is my code:

Sorting By Word?
Okay, I am making a member database, and when I print it out I want it to display the list by rank. Unfortantly, I stored Rank as a word. I could make a sort function that would be quite extensive and probably take a long time to execute every time...


..Or, is there anyway I can specify in SQL: Put this on the top of the list if "rank='General'" and then next if "rank='Captain'", and so on? I think if this was possible it would take a lot less time to execute...

Or else I will probably have to redesign much of the site with numerical ranks instead. Thanks for any answers/advice.

Word & Excel To PDF
I need to convert the DOC (Word and Excel) files in to PDF through PHP code
in my web. According to requirement whenever the user upload the .Doc file
code should convert that .Doc file into .PDF file at runtime.

I am using Linux-PHP-MySQL Technolgoies for development.

I am expecting suggestions and help from expert friends who can help me out
to achive this.

Open Word From PHP
I am trying to open up word documents, in word, from php. The documents are stored on a web server and access by web dav. when I try opening from php the word documents open in a web browser. If I open word then paste the url in it will open the document in word.

Does anyone know of a way of sending a file and getting it to open in word rather than a browser from php.

Word Count
I have a form which users can write a letter and outputs it as $letter - done this, but I need something to count the number of words written.

What Is The Missing Word?
Ascii table alert!

SQL-like database General
================= =======
column field
row record
table ???

What is the missing word?


Copyright © 2005-08 www.BigResource.com, All rights reserved