Question

RTF or Word File Parser

Asked by: d2kagw

Hi there,

im building a CMS system, and i'd really like to have a word import/export tool...

does anyone know of a extension or script that will allow PHP to read/write RTF or Word Files?

Cheers

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2005-01-10 at 17:05:24ID21269243
Tags

rtf

,

php

,

parser

Topic

PHP Scripting Language

Participating Experts
3
Points
500
Comments
4

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. RTF TO TEXT
    Is there any program/utility/function that can convert a RTF document into a text file? Thx
  2. RTF and Excel  ???
    Hi Guys, How do I open a RTF file with excel. Please don't tell me to open it with word & export. Doug
  3. RTF question
    Hi, I have a CString object and I want to know if the string is in RTF format or in a simple text format. Is there a function that answer this question ? thanks, Yoav.
  4. RTF
    experts, Is there any posible way to count the number of lines on RTF? and if the number of lines achive the defined maximum number of lines it will authomaticaly go to the next page but the same form template. I need this on my ISO documentation.. thanks..
  5. Export to rtf file without opening a window
    Hello all I have a php site which manages a databse of calendar events On one page the admin staff have the ability to create an rtf file from events in the database (this we will send to our printers to print the calendar). I use a link on the page which calls a Javascript...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: sgalzinPosted on 2005-01-10 at 17:58:34ID: 13009627

Hi,

Here is an RTF to HTML parser :
http://100net.mirrors.phpclasses.org/browse/package/119.html

I haven't tried it, but it seems to say only simple RTF documents are understood. Would that be sufficient for you ?

If you need to create RTF files, here is a good link :
http://lab.artlung.com/php/rtf/

Hope that helps,

Stephane.

 

by: iceboxmanPosted on 2005-01-10 at 18:03:30ID: 13009658

This will only work on a windows server:
http://p2p.wrox.com/topic.asp?TOPIC_ID=22614

If you want to actually parse the binary word file, I don't think there is any code to do that.  As for parsing RTF...hmmm.  I should make something in PHP since I used to know RTF.  Maybe a future project...

Also see:
http://www.granneman.com/techinfo/windows/extractcontentfromword.htm

 

by: JoshPowellPosted on 2005-01-11 at 12:13:57ID: 13017665

sgalzin, you have to be a subscriber to download that file.

Here is an RTF parer that I have found..


<?
      // use tabstop=4

      /*
            Rich Text Format - Parsing Class
            ================================

            (c) 2000 Markus Fischer
            <mfischer@josefine.ben.tuwien.ac.at>
               http://josefine.ben.tuwien.ac.at/~mfischer/

            Latest versions of this class can always be found at
                  http://josefine.ben.tuwien.ac.at/~mfischer/developing/php/rtf/rtfclass.phps
            Testing suite is available at
                  http://josefine.ben.tuwien.ac.at/~mfischer/developing/php/rtf/

            License: GPLv2

            Specification:
                  http://msdn.microsoft.com/library/default.asp?URL=/library/specs/rtfspec.htm

            General Notes:
            ==============
            Unknown or unspupported control symbols are silently ignored

            Group stacking is still not supported :(
                  group stack logic implemented; however not really used yet

            Example on how to use this class:
            =================================

            $r = new rtf( stripslashes( $rtf));
            $r->output( "xml");
            $r->parse();
            if( count( $r->err) == 0) // no errors detected
                  echo $r->out;
                  
            History:
            ========
            Sat Nov 25 09:52:12 CET 2000      mfischer
                  First version which has useable but only well-formed xml output; rtf
                  data structure is only logically rebuild, no real parsing yet

            Mon Nov 27 16:17:18 CET 2000      mfischer
                  Wrote handler for \plain control word (thanks to Peter Kursawe for this
                  one)

            Tue Nov 28 02:22:16 CET 2000      mfischer
                  Implemented alignment (left, center, right) with HTML <DIV .. tags
                  Also implemented translation for < and > character when outputting html or xml

            Remarks:
            ========
            This class and all work done here is dedicated to Tatjana.
      */

      /* was just a brainlag suggestion of my inner link; don't know if I'll use it */
      class rtfState {
            var $bold;
            var $italic;
            var $underlined;
      }

      class rtf {
            var $rtf;            // rtf core stream
            var $len;            // length in characters of the stream (get performace due avoiding calling strlen everytime)
            var $err = array();            // array of error message, no entities on no error

            var $wantXML;      // convert to XML
            var $wantHTML;      // convert to HTML

            // the only variable which should be accessed from the outside
            var $out;            // output data stream (depends on which $wantXXXXX is set to true
            var $outstyles;      // htmlified styles (generated after parsing if wantHTML
            var $styles;      // if wantHTML, stylesheet definitions are put in here

            // internal parser variables --------------------------------
            // control word variables
            var $cword;            // holds the current (or last) control word, depending on $cw
            var $cw;            // are we currently parsing a control word ?
            var $cfirst;      // could this be the first character ? so watch out for control symbols

            var $flags = array();            // parser flags

            var $queue;            // every character which is no sepcial char, not belongs to a control word/symbol; is generally considered being 'plain'

            var $stack = array();      // group stack

            /* keywords which don't follw the specification (used by Word '97 - 2000) */
            // not yet used
            var $control_exception = array(
                  "clFitText",
                  "clftsWidth(-?[0-9]+)?",
                  "clNoWrap(-?[0-9]+)?",
                  "clwWidth(-?[0-9]+)?",
                  "tdfrmtxtBottom(-?[0-9]+)?",
                  "tdfrmtxtLeft(-?[0-9]+)?",
                  "tdfrmtxtRight(-?[0-9]+)?",
                  "tdfrmtxtTop(-?[0-9]+)?",
                  "trftsWidthA(-?[0-9]+)?",
                  "trftsWidthB(-?[0-9]+)?",
                  "trftsWidth(-?[0-9]+)?",
                  "trwWithA(-?[0-9]+)?",
                  "trwWithB(-?[0-9]+)?",
                  "trwWith(-?[0-9]+)?",
                  "spectspecifygen(-?[0-9]+)?"
                  );

            var $charset_table = array(
                  "0"      =>      "ANSI",
                  "1"      =>      "Default",
                  "2"      =>      "Symbol",
                  "77" =>      "Mac",
                  "128" =>      "Shift Jis",
                  "129" =>      "Hangul",
                  "130" =>      "Johab",
                  "134" =>      "GB2312",
                  "136" =>      "Big5",
                  "161" =>      "Greek",
                  "162" =>      "Turkish",
                  "163" =>      "Vietnamese",
                  "177" =>      "Hebrew",
                  "178" =>      "Arabic",
                  "179" =>      "Arabic Traditional",
                  "180" =>      "Arabic user",
                  "181" =>      "Hebrew user",
                  "186" =>      "Baltic",
                  "204" =>      "Russion",
                  "222" =>      "Thai",
                  "238" =>      "Eastern European",
                  "255" =>      "PC 437",
                  "255" =>      "OEM"
            );

            /* note: the only conversion table used */
            var $fontmodifier_table = array(
                  "bold"      =>      "b",
                  "italic"      => "i",
                  "underlined"      => "u",
                  "strikethru"      => "strike"
            );

            /*
                  Class Constructor:
                  Takes as argument the raw RTF stream
                  (Note under certain circumstances the stream has to be stripslash'ed before handling over)
                  Initialises some class-global variables
            */
            function rtf( $data) {
                  $this->len = strlen( $data);
                  $this->rtf = $data;

                  $this->wantXML = false;
                  $this->wantHTML = false;

                  $this->out = "";
                  $this->outstyles = "";
                  $this->styles = array();
                  $this->text = "";

                  if( $this->len == 0)
                        array_push( $this->err, "No data in stream found");
            }

            function parserInit() {
                  /*
                        Default values according to the specs
                  */
                  $this->flags = array(
                        "fontsize"      =>      24,
                        "beginparagraph"      => true
                  );
            }
            
            /*
                  Sets the output type
            */
            function output( $typ) {
                  switch( $typ) {
                        case "xml": $this->wantXML = true; break;
                        case "html": $this->wantHTML = true; break;
                        default: break;
                  }
            }

            function parseControl( $control, $parameter) {
                  switch( $control) {
                        // font table definition start
                        case "fonttbl":
                              $this->flags["fonttbl"] = true;      // signal fonttable control words they are allowed to behave as expected
                              break;
                        // define or set font
                        case "f":
                              if( $this->flags["fonttbl"]) {      // if its set, the fonttable definition is written to; else its read from
                                    $this->flags["fonttbl_current_write"] = $parameter;
                              } else {
                                    $this->flags["fonttbl_current_read"] = $parameter;
                              }
                              break;
                        case "fcharset":
                              // this is for preparing flushQueue; it then moves the Queue to $this->fonttable .. instead to formatted output
                              $this->flags["fonttbl_want_fcharset"] = $parameter;
                              break;
                        case "fs":
                              // sets the current fontsize; is used by stylesheets (which are therefore generated on the fly
                              $this->flags["fontsize"] = $parameter;
                              break;
                        // handle alignment
                        case "qc":
                              $this->flags["alignment"] = "center";
                              break;
                        case "qr":
                              $this->flags["alignment"] = "right";
                              break;
                        // reset paragraph settings ( only alignment)
                        case "pard":
                              $this->flags["alignment"] = "";
                              break;
                        // define new paragraph (for now, thats a simple break in html)
                        case "par":
                              // begin new line
                              $this->flags["beginparagraph"] = true;
                              if( $this->wantHTML) {
                                    $this->out .= "</div>";
                              }
                              break;
                        // bold
                        case "bnone":
                              $parameter = "0";
                        case "b":
                              // haven'y yet figured out WHY I need a (string)-cast here ... hm
                              if( (string)$parameter == "0")
                                    $this->flags["bold"] = false;
                              else
                                    $this->flags["bold"] = true;
                              break;

                        // underlined
                        case "ulnone":
                              $parameter = "0";
                        case "ul":
                              if( (string)$parameter == "0")
                                    $this->flags["underlined"] = false;
                              else
                                    $this->flags["underlined"] = true;
                              break;
                        
                        // italic
                        case "inone":
                              $parameter = "0";
                        case "i":
                              if( (string)$parameter == "0")
                                    $this->flags["italic"] = false;
                              else
                                    $this->flags["italic"] = true;
                              break;

                        // strikethru
                        case "strikenone":
                              $parameter = "0";
                        case "strike":
                              if( (string)$parameter == "0")
                                    $this->flags["strikethru"] = false;
                              else
                                    $this->flags["strikethru"] = true;
                              break;

                        // reset all font modifiers and fontsize to 12
                        case "plain":
                              $this->flags["bold"] = false;
                              $this->flags["italic"] = false;
                              $this->flags["underlined"] = false;
                              $this->flags["strikethru"] = false;
                              $this->flags["fontsize"] = 12;

                              $this->flags["subscription"] = false;
                              $this->flags["superscription"] = false;
                              break;

                        // sub and superscription
                        case "subnone":
                              $parameter = "0";
                        case "sub":
                              if( (string)$parameter == "0")
                                    $this->flags["subscription"] = false;
                              else
                                    $this->flags["subscription"] = true;
                              break;

                        case "supernone":
                              $parameter = "0";
                        case "super":
                              if( (string)$parameter == "0")
                                    $this->flags["superscription"] = false;
                              else
                                    $this->flags["superscription"] = true;
                              break;
                              
                  }
            }

            /*
                  Dispatch the control word to the output stream
            */
            function flushControl() {
                  if( ereg( "^([A-Za-z]+)(-?[0-9]*) ?$", $this->cword, $match)) {

                        $this->parseControl( $match[1], $match[2]);

                        if( $this->wantXML) {
                              $this->out.="<control word=\"".$match[1]."\"";
                              if( strlen( $match[2]) > 0)
                                    $this->out.=" param=\"".$match[2]."\"";
                              $this->out.="/>";
                        }
                  }
            }

            /*
                  If output stream supports comments, dispatch it
            */
            function flushComment( $comment) {
                  if( $this->wantXML || $this->wantHTML) {
                        $this->out.="<!-- ".$comment." -->";
                  }
            }

            /*
                  Dispatch start/end of logical rtf groups
                  (not every output type needs it; merely debugging purpose)
            */
            function flushGroup( $state) {
                  if( $state == "open") {

                        /* push onto the stack */
                        array_push( $this->stack, $this->flags);
                  
                        if( $this->wantXML)
                              $this->out.="<group>";
                  }
                  if( $state == "close") {

                        /* pop from the stack */
                        $this->last_flags = $this->flags;
                        $this->flags = array_pop( $this->stack);

                        $this->flags["fonttbl_current_write"] = ""; // on group close, no more fontdefinition will be written to this id
                                                                                          // this is not really the right way to do it !
                                                                                          // of course a '}' not necessarily donates a fonttable end; a fonttable
                                                                                          // group at least *can* contain sub-groups
                                                                                          // therefore an stacked approach is heavily needed
                        $this->flags["fonttbl"] = false; // no matter what you do, if a group closes, its fonttbl definition is closed too

                        if( $this->wantXML)
                              $this->out.="</group>";
                  }
            }

            function flushHead() {
                  if( $this->wantXML)
                        $this->out.="<rtf>";
            }

            function flushBottom() {
                  if( $this->wantXML)
                        $this->out.="</rtf>";
            }


            function checkHtmlSpanContent( $command) {
                  reset( $this->fontmodifier_table);
                  while( list( $rtf, $html) = each( $this->fontmodifier_table)) {
                        if( $this->flags[$rtf] == true) {
                              if( $command == "start")
                                    $this->out .= "<".$html.">";
                              else
                                    $this->out .= "</".$html.">";
                        }
                  }
            }
            /*
                  flush text in queue
            */
            function flushQueue() {
                  if( strlen( $this->queue)) {
                        // processing logic
                        if( ereg( "^[0-9]+$", $this->flags["fonttbl_want_fcharset"])) {
                              $this->fonttable[$this->flags["fonttbl_want_fcharset"]]["charset"] = $this->queue;
                              $this->flags["fonttbl_want_fcharset"] = "";
                              $this->queue = "";
                        }
                        
                        // output logic
                        if( strlen( $this->queue)) {
                              /*
                                    Everything which passes this is (or, at leat, *should*) be only outputted plaintext
                                    Thats why we can safely add the css-stylesheet when using wantHTML
                              */
                              if( $this->wantXML)
                                    $this->out.= "<plain>".$this->queue."</plain>";

                              if( $this->wantHTML) {
                                    // only output html if a valid (for now, just numeric;) fonttable is given
                                    if( ereg( "^[0-9]+$", $this->flags["fonttbl_current_read"])) {
                                          
                                          if( $this->flags["beginparagraph"] == true) {
                                                $this->flags["beginparagraph"] = false;
                                                $this->out .= "<div align=\"";
                                                switch( $this->flags["alignment"]) {
                                                      case "right":
                                                            $this->out .= "right";
                                                            break;
                                                      case "center":
                                                            $this->out .= "center";
                                                            break;
                                                      case "left":
                                                      default:
                                                            $this->out .= "left";
                                                }
                                                $this->out .= "\">";
                                          }
                                          
                                          /* define new style for that span */
                                          $this->styles["f".$this->flags["fonttbl_current_read"]."s".$this->flags["fontsize"]] = "font-family:".$this->fonttable[$this->flags["fonttbl_current_read"]]["charset"]." font-size:".$this->flags["fontsize"].";";
                                          /* write span start */
                                          $this->out .= "<span class=\"f".$this->flags["fonttbl_current_read"]."s".$this->flags["fontsize"]."\">";

                                          /* check if the span content has a modifier */
                                          $this->checkHtmlSpanContent( "start");
                                          /* write span content */
                                          $this->out .= $this->queue;
                                          /* close modifiers */
                                          $this->checkHtmlSpanContent( "stop");
                                          /* close span */
                                          "</span>";
                                    }
                              }
                              $this->queue = "";
                        }
                  }
            }

            /*
                  handle special charactes like \'ef
            */
            function flushSpecial( $special) {
                  if( strlen( $special) == 2) {
                        if( $this->wantXML)
                              $this->out .= "<special value=\"".$special."\"/>";
                  }
            }

            /*
                  Output errors at end
            */
            function flushErrors() {
                  if( count( $this->err) > 0) {
                        if( $this->wantXML) {
                                    $this->out .= "<errors>";
                                    while( list($num,$value) = each( $this->err)) {
                                          $this->out .= "<message>".$value."</message>";
                                    }
                                    $this->out .= "</errors>";
                        }
                  }
            }

            function makeStyles() {
                  $this->outstyles = "<style type=\"text/css\"><!--\n";
                  reset( $this->styles);
                  while( list( $stylename, $styleattrib) = each( $this->styles)) {
                        $this->outstyles .= ".".$stylename." { ".$styleattrib." }\n";
                  }
                  $this->outstyles .= "--></style>\n";
            }

            /*
                  finally ..

                  How this parser (is supposed) to work:
                  ======================================
                  This parse simple starts at the beginning of the rtf core stream, catches every
                  controlling character {,} and \, automatically builds control words and control
                  symbols during his livetime, trashes every other character into the plain text
                  queue
            */
            function parse() {

                  $this->parserInit();

                  $i = 0;
                  $this->cw= false;      // flag if control word is currently parsed
                  $this->cfirst = false;// first control character ?
                  $this->cword = "";      // last or current control word ( depends on $this->cw

                  $this->queue = "";            // plain text data found during parsing

                  $this->flushHead();

                  while( $i < $this->len) {
                        switch( $this->rtf[$i]) {
                              case "{":      if( $this->cw) {
                                                      $this->flushControl();
                                                      $this->cw= false; $this->cfirst = false;
                                                } else
                                                      $this->flushQueue();

                                                $this->flushGroup( "open");
                                                break;
                              case "}":      if( $this->cw) {
                                                      $this->flushControl();
                                                      $this->cw= false; $this->cfirst = false;
                                                } else
                                                      $this->flushQueue();

                                                $this->flushGroup( "close");
                                                break;
                              case "\\":      if( $this->cfirst) {      // catches '\\'
                                                      $this->queue .= '\\';
                                                      $this->cfirst = false;
                                                      $this->cw= false;
                                                      break;
                                                }
                                                if( $this->cw) {
                                                      $this->flushControl();
                                                } else
                                                      $this->flushQueue();
                                                $this->cw = true;
                                                $this->cfirst = true;
                                                $this->cword = "";
                                                break;
                              default:      
                                                if( (ord( $this->rtf[$i]) == 10) || (ord($this->rtf[$i]) == 13)) break; // eat line breaks
                                                if( $this->cw) {      // active control word ?
                                                      /*
                                                            Watch the RE: there's an optional space at the end which IS part of
                                                            the control word (but actually its ignored by flushControl)
                                                      */
                                                      if( ereg( "^[a-zA-Z0-9-]?$", $this->rtf[$i])) { // continue parsing
                                                            $this->cword .= $this->rtf[$i];
                                                            $this->cfirst = false;
                                                      } else {
                                                            /*
                                                                  Control word could be a 'control symbol', like \~ or \* etc.
                                                            */
                                                            $specialmatch = false;
                                                            if( $this->cfirst) {
                                                                  if( $this->rtf[$i] == '\'') { // expect to get some special chars
                                                                        $this->flushQueue();
                                                                        $this->flushSpecial( $this->rtf[$i+1].$this->rtf[$i+2]);
                                                                        $i+=2;
                                                                        $specialmatch = true;
                                                                        $this->cw = false; $this->cfirst = false; $this->cword = "";
                                                                  } else
                                                                  if( ereg( "^[{}\*]$", $this->rtf[$i])) {
                                                                        $this->flushComment( "control symbols not yet handled");
                                                                        $specialmatch = true;
                                                                  }
                                                                  $this->cfirst = false;
                                                            } else {
                                                                  if( $this->rtf[$i] == ' ') {      // space delimtes control words, so just discard it and flush the controlword
                                                                        $this->cw = false;
                                                                        $this->flushControl();
                                                                        break;
                                                                  }
                                                            }
                                                            if( ! $specialmatch) {
                                                                  $this->flushControl();
                                                                  $this->cw = false; $this->cfirst = false;
                                                                  /*
                                                                        The current character is a delimeter, but is NOT
                                                                        part of the control word so we hop one step back
                                                                        in the stream and process it again
                                                                  */
                                                                  $i--;
                                                            }
                                                      }
                                                } else {
                                                      // < and > need translation before putting into queue when XML or HTML is wanted
                                                      if( ($this->wantHTML) || ($this->wantXML)) {
                                                            switch( $this->rtf[$i]) {
                                                                  case "<":
                                                                        $this->queue .= "&lt;";
                                                                        break;
                                                                  case ">":
                                                                        $this->queue .= "&gt;";
                                                                        break;
                                                                  default:
                                                                        $this->queue .= $this->rtf[$i];
                                                                        break;
                                                            }
                                                      } else
                                                            $this->queue .= $this->rtf[$i];
                                                }
                                                      
                        }
                        $i++;
                  }
                  $this->flushQueue();
                  $this->flushErrors();
                  $this->flushBottom();

                  if( $this->wantHTML) {
                        $this->makeStyles();
                  }
            }
      }
?>



Hope this helps,
Josh

 

by: iceboxmanPosted on 2005-01-11 at 16:18:55ID: 13019780

Cool.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...