public string traducirTexto()
        {
            //Cabecera del documento HTML resultante
            string res = "<html><head></head><body>";

            //Se establece el estado inicial por defecto
            estadoActual = new EstadoRtf((string)tFuentes[0], 10, (Color)tColores[0], false, false, false);

            //Se aplica el formato inicial definido en 'estadoActual'
            inicioFormato();

            //Se busca el indice del primer nodo perteneciente al texto
            bool enc = false;                           //Encontrado el comienzo del texto
            int  i   = 0;

            RtfTreeNode nodo = new RtfTreeNode();

            while (!enc && i < tree.RootNode.FirstChild.ChildNodes.Count)
            {
                nodo = tree.RootNode.FirstChild.ChildNodes[i];

                //El texto comenzará tras el primer token "\pard"
                if (nodo.NodeKey == "pard")
                {
                    enc = true;
                }

                i++;
            }

            //La búsqueda anterior del primer nodo "\pard" se puede sustituir por
            //la siguiente linea en la versión v0.2 de la librería NRtfTree:
            //

            //Se comenzará a traducir a partir del nodo en la posición 'primerNodoTexto'
            int primerNodoTexto = i - 1;

            //Inmersion
            res += traducirTexto(tree.RootNode.FirstChild, primerNodoTexto);

            //Se finaliza el estado inicial
            res += finFormato();

            //Finaliza el documento HTML
            res += "</body></html>";

            return(res);
        }
        public string traducirTexto(RtfTreeNode curNode, int prim)
        {
            string res = "";

            //Grupo actual
            RtfTreeNode nprin = curNode;

            RtfTreeNode nodo = new RtfTreeNode();

            for (int i = prim; i < nprin.ChildNodes.Count; i++)
            {
                nodo = nprin.ChildNodes[i];

                if (nodo.NodeType == RtfNodeType.Group)
                {
                    //Se apila el estado actual
                    estados.Add(estadoActual);

                    //Se crea un nueo estado inicial
                    estadoActual = new EstadoRtf((string)tFuentes[0], 10, (Color)tColores[0], false, false, false);

                    res += traducirTexto(nodo, 0);

                    //Se desapila el estado anterior
                    estadoActual = (EstadoRtf)estados[estados.Count - 1];
                    estados.RemoveAt(estados.Count - 1);
                }
                else if (nodo.NodeType == RtfNodeType.Control)
                {
                    if (nodo.NodeKey == "'")
                    {
                        res += inicioFormato();
                        res += (char)nodo.Parameter;
                        res += finFormato();
                    }
                }
                else if (nodo.NodeType == RtfNodeType.Keyword)
                {
                    switch (nodo.NodeKey)
                    {
                    case "f":                              //Tipo de fuente
                        estadoActual.fuente = (string)tFuentes[nodo.Parameter];
                        break;

                    case "cf":                              //Color de fuente
                        estadoActual.color = (Color)tColores[nodo.Parameter];
                        break;

                    case "fs":                                  //Tamaño de fuente
                        estadoActual.tamFuente = nodo.Parameter;
                        break;

                    case "b":                                   //Negrita
                        if (!nodo.HasParameter || nodo.Parameter == 1)
                        {
                            estadoActual.negrita = true;
                        }
                        else
                        {
                            estadoActual.negrita = false;
                        }
                        break;

                    case "i":                                   //Cursiva
                        if (!nodo.HasParameter || nodo.Parameter == 1)
                        {
                            estadoActual.cursiva = true;
                        }
                        else
                        {
                            estadoActual.cursiva = false;
                        }
                        break;

                    case "ul":                                  //Subrayado ON
                        estadoActual.subrayado = true;
                        break;

                    case "ulnone":                              //Subrayado OFF
                        estadoActual.subrayado = false;
                        break;

                    case "par":                                 //Nuevo párrafo
                        res += "<br>";
                        break;
                    }
                }
                else if (nodo.NodeType == RtfNodeType.Text)
                {
                    res += inicioFormato();
                    res += nodo.NodeKey;
                    res += finFormato();
                }
            }

            return(res);
        }