ConvertHtmlToRtf() public method

public ConvertHtmlToRtf ( string htmlText ) : string
htmlText string
return string
Exemplo n.º 1
0
        void GetRTF()
        {
            MarkupConverter.MarkupConverter markupConverter = new MarkupConverter.MarkupConverter();
            StringBuilder html = new StringBuilder("<Table>");
            string        temp;

            foreach (SelectTextosPrimaPresentacion_Result texto in obs)
            {
                html.Append("<tr><td><b>");
                if (string.IsNullOrEmpty(texto.texto1))
                {
                    html.Append("&nbsp;");
                }
                else
                {
                    html.Append(texto.texto1);
                }

                html.Append("</b></td><td>");

                if (string.IsNullOrEmpty(texto.texto2))
                {
                    html.Append("&nbsp;");
                }
                else
                if (texto.texto2.Contains("<br>"))
                {
                    foreach (string valor in texto.texto2.Split(new string[] { "<br>" }, StringSplitOptions.None))
                    {
                        temp = valor.StartsWith("&nbsp;") ? "." + valor: valor;
                        html.Append(temp);
                        html.Append("</td></tr><tr><td><b>&nbsp;</b></td><td>");
                    }
                }
                else
                {
                    html.Append(texto.texto2);
                }

                html.Append("</td></tr>");
            }
            html.Append("</table>");

            rtf = markupConverter.ConvertHtmlToRtf(html.ToString());

            rtf = rtf.Replace("cellx1440", "cellx3502").Replace("cellx2880", "cellx11136").Replace(@"clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\", "");
        }