 |
 | Many Thanks BruceG | 12:55 17 Feb '09 |
|
 |
I have been looking all over for something like this, a rich-text parser that I could use in my VB 2005 project to break out the keywords from the text in order to perform a couple of specific operations on the text. Although I had some issues in converting the C# source to VB, I just used the DLL and it works fine. This has been a savior. Thanks very much for putting this out there.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I just want to say thanks to you for this excellent piece of work. Your RTF-to-HTML is a real savior for me even though it's not working perfectly. I'm also looking forward to checking out your next version. Thanks again.
Lee
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | When will the final version of v0.3.0 be available? kmillard59 | 10:23 24 Nov '08 |
|
 |
The beta 1 version was released back in February of 2007. We have run into several issues with the beta 1 release most notably is the OutOfMemory exception in RtfLex.
|
| Sign In·View Thread·PermaLink | 3.25/5 |
|
|
|
 |
 | RtfTree not working even i have given refence of .DLL spatil1982 | 1:48 21 Nov '08 |
|
|
 |
 | Wrong dimension wmetafile images NickBlu | 19:50 11 Nov '08 |
|
 |
Why wmetafile image dimensions, when are extracted with application, appears differents from what selected via \picwgoal and \pichgoal tags? Seems application it is "insensible" to parameter picgoal. When application extracts wmetafile image content in "example1-images.rtf" of examples (they ar hidden, in file), it create WMF file with dimension not correct (cfr. jpg image from same file...). Help me!!! 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | NRtfTree Merge multiple RTF doc BoFabio | 1:01 24 Oct '08 |
|
 |
Hi Oliver, i've added a new class capable to make multiple RTF doc merge. I am very plase to add my class to your project.
Plase contact me i will send you source file.
Regards
Sample Code:
private void cmdMerge_Click(object sender, EventArgs e) { // create main Rtf doc and insert into main doc rtf placeholder
RtfDocument doc = new RtfDocument("..\\..\\SampleDoc\\RtfDoc.rtf"); RtfTextFormat textFmt = new RtfTextFormat(); textFmt.font = "Times New Roman"; textFmt.bold = true; doc.AddText("[TagTextRTF1] Test File with placeholder [TagTextRTF1], place holder will be replaced with RTF file. Second Place holder into same line [TagTextRTF2].", textFmt); textFmt.bold = false; textFmt.underline = true; textFmt.color = Color.Red; doc.AddText("Second text (RED underlined text) with following place holder [TagTextRTF2]", textFmt); doc.Close();
// create first to merge rtf doc doc = new RtfDocument("..\\..\\SampleDoc\\ToMerge1.rtf"); textFmt = new RtfTextFormat(); textFmt.font = "Georgia"; textFmt.color = Color.Blue; textFmt.bold = false; doc.AddText("(Hi, i'm RTF content of your 1st placeholder)", textFmt); doc.Close();
// create second to merge rtf doc doc = new RtfDocument("..\\..\\SampleDoc\\ToMerge2.rtf"); textFmt = new RtfTextFormat(); textFmt.font = "Verdana"; textFmt.color = Color.Green; textFmt.bold = false; doc.AddText("(Hi, i'm RTF content of your 2nd placeholder)", textFmt); doc.Close();
RtfMerger oTree = new RtfMerger(); oTree.MergeRtfDoc("..\\..\\SampleDoc\\RtfDoc.rtf", "\\[TagTextRTF(\\w+)\\]", new OtherRtfDocDelegate(manageDocToInsert), "..\\..\\SampleDoc\\Result.rtf", false,true); MessageBox.Show("Test ended!"); }
public void manageDocToInsert(ref RtfTree docToInsert, string strText , string strPHParam, ref string strCompletePlaceHolder) { if (strPHParam == "1") { docToInsert = new RtfTree(); docToInsert.LoadRtfFile("..\\..\\SampleDoc\\ToMerge1.rtf"); } if (strPHParam == "2") { docToInsert = new RtfTree(); docToInsert.LoadRtfFile("..\\..\\SampleDoc\\ToMerge2.rtf"); } }
BoFabio
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi Fabio,
Actually, i'm now working on the merging rtf files. I'm wondering if your classes can merge any 2 rtf files(the 2 rtf files' format may have many differences)? Would you please share your source codes?(My email:kevin[dot]yank[at]gmail[dot]com)
Many thanks Kevin 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | NRtfTree bug fix BoFabio | 0:53 24 Oct '08 |
|
 |
Hi Olivel, compliment for your good job. I've discovered a couple of small bugs in your job. How can i send to you this bug fixing? Reading complex rtf i've discovered fonttbl big issues. Fonttbl font are not enumerated from 0 to last font in progressive order, sometimes we have a non continuous range. For example we could have four different font in fonttbl managed as follow: font 0, font 1, font 4 and font 5. I've modified RtfFontTable and RtfTree source.
Contact me as soon
Thank you
Fabio
BoFabio
modified on Friday, October 24, 2008 6:09 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
 | bugfix Member 2264125 | 1:20 21 Aug '08 |
|
 |
There's a bug - characters '{', '}' and '\\' aren't prefixed with '\\' in AppendEncoded method
To fix it add this code into AppendEncoded in the loop right before "int code = Char.ConvertToUtf32(s, i);":
if ((s[i] == '{') || (s[i] == '}') || (s[i] == '\\')) { res.Append(@"\"); }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | TraductorRtf in Delphi Nicolò Blunda | 12:17 8 Aug '08 |
|
 |
I have translated code of TraductorRtf (for RTF2HTML conversion) in Delphi-pascal and it works very well. Images must be saved before and RTF code must be replaced with reference at their location.... Here is code. Buona fortuna.
{* ************************************************************************** * This file is part of NRtfTree. * * NRtfTree is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * NRtfTree is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NRtfTree; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA **************************************************************************************************************************************************** * Library: NRtfTree * Version: v0.2.1 * Class: ImageNode * Copyright: 2005 Salvador Gomez * Home Page: http: * SF Project: http: * http: * Date: 10/12/2006 * Description: Conversor simple de RTF a HTML (Demo NRtfTree) * Translated from C# to Delphi: 2008 Nicolò Blunda ***************************************************************************} UNIT TraductorRtf;
INTERFACE
USES System.Collections, System.Drawing, System.Drawing.Drawing2D, Borland.Vcl.SysUtils, Net.Sgoliver.NRtfTree.Core, Net.Sgoliver.NRtfTree.Util;
TYPE EstadoRtf = class public negrita: Boolean; cursiva: Boolean; subrayado: Boolean; fuente: string; tamFuente: Integer; color: Color; public constructor Create(fue: string; tam: Integer; col: Color; neg: Boolean; cur: Boolean; sub: Boolean); end;
TArrayOfString = array of string; TArrayOfColor = array of Color;
TraductorRtf = class strict private tree: RtfTree; tFuentes: TArrayOfString; tColores: TArrayOfColor; estados: ArrayList; estadoActual: EstadoRtf; public constructor Create(TextRTF: string); function traducir: string; function traducTexto: string; function traducirTexto(curNode: RtfTreeNode; prim: Integer): string; function inicioFormato: string; function finFormato: string; function toHTMLColor(actColor: Color): string; function intToHex(hexint: Integer; lungh: Integer): string; end;
IMPLEMENTATION
constructor EstadoRtf.Create(fue: string; tam: Integer; col: Color; neg: Boolean; cur: Boolean; sub: Boolean); begin inherited Create; Self.fuente := fue; Self.tamFuente := tam; Self.color := col; Self.negrita := neg; Self.cursiva := cur; Self.subrayado := sub; end;
constructor TraductorRtf.Create(TextRTF: string); begin inherited Create; Self.estados := ArrayList.Create; Self.tree := RtfTree.Create; Self.tree.LoadRtfText(TextRTF); end;
function TraductorRtf.traducir: string; Begin Result:= ''; Self.tFuentes := Self.tree.GetFontTable; Self.tColores := Self.tree.GetColorTable; Result:= traducTexto; End;
function TraductorRtf.traducTexto: string; var primerNodoTexto: Integer; nodo: RtfTreeNode; i: Integer; enc: Boolean; res: string; Begin res:= '<html><head></head><body>'; Self.estadoActual:= EstadoRtf.Create((string(Self.tFuentes[0])), 10, (Color(Self.tColores[0])), False, False, False); inicioFormato; enc := False; i := 0; nodo := RtfTreeNode.Create; while ((not enc ) and (i < Self.tree.RootNode.FirstChild.ChildNodes.Count)) do begin nodo := Self.tree.RootNode.FirstChild.ChildNodes[i]; enc := (nodo.NodeKey = 'pard'); Inc(i); end; primerNodoTexto := (i - 1); res:= res + traducirTexto(tree.RootNode.FirstChild, primerNodoTexto); res:= res + finFormato; res:= res + '</body></html>'; Result:= res; End; {traducTexto}
function TraductorRtf.traducirTexto(curNode: RtfTreeNode; prim: Integer): string; var i: Integer; nodo: RtfTreeNode; nprin: RtfTreeNode; res: string; Begin res := ''; nprin := curNode; nodo := RtfTreeNode.Create; for i:= prim to nprin.ChildNodes.Count - 1 do begin nodo := nprin.ChildNodes[i]; if (nodo.NodeType = RtfNodeType.Group) then begin Self.estados.Add(Self.estadoActual); Self.estadoActual := EstadoRtf.Create((string(Self.tFuentes[0])), 10, (Color(Self.tColores[0])), False, False, False); res:= res + traducirTexto(nodo,0); Self.estadoActual := (EstadoRtf(Self.estados[(Self.estados.Count - 1)])); Self.estados.RemoveAt((Self.estados.Count - 1)); end else if (nodo.NodeType = RtfNodeType.Control) then begin if (nodo.NodeKey = '''') then begin res:= res + inicioFormato; res:= res + Char(nodo.Parameter); res:= res + finFormato; end end else if (nodo.NodeType = RtfNodeType.Keyword) then begin if nodo.NodeKey='f' then estadoActual.fuente:= tFuentes[nodo.Parameter] else if nodo.NodeKey='cf' then estadoActual.color:= tColores[nodo.Parameter] else if nodo.NodeKey='fs' then estadoActual.tamFuente:= nodo.Parameter else if nodo.NodeKey='b' then estadoActual.negrita:= (not nodo.HasParameter or (nodo.Parameter=1)) else if nodo.NodeKey='i' then estadoActual.cursiva:= (not nodo.HasParameter or (nodo.Parameter=1)) else if nodo.NodeKey='ul' then estadoActual.subrayado:= true else if nodo.NodeKey='ulnone' then estadoActual.subrayado:= false else if nodo.NodeKey='par' then res:= res + '<br>'; end else if (nodo.NodeType = RtfNodeType.Text) then begin res := res + inicioFormato; res := res + nodo.NodeKey; res := res + finFormato; end; end; {for i} Result := res; End; {traducirTexto}
function TraductorRtf.inicioFormato: string; var res: string; begin res:= ''; res:= '<font face=''' + estadoActual.fuente + ''' size=''' + FloatToStr(Int(estadoActual.tamFuente/8)) + ''' color=''' + toHTMLColor(estadoActual.color) + '''>'; if Self.estadoActual.negrita then res:= res + '<b>'; if Self.estadoActual.cursiva then res:= res + '<i>'; if Self.estadoActual.subrayado then res:= res + '<u>'; Result := res; end;
function TraductorRtf.finFormato: string; var res: string; begin res := ''; if Self.estadoActual.negrita then res:= res + '</b>'; if Self.estadoActual.cursiva then res:= res + '</i>'; if Self.estadoActual.subrayado then res:= res + '</u>'; Result := res; end;
function TraductorRtf.toHTMLColor(actColor: Color): string; Begin Result := ((('#' + intToHex(actColor.R, 2)) + intToHex(actColor.G, 2)) + intToHex(actColor.B, 2)); End;
function TraductorRtf.intToHex(hexint: Integer; lungh: Integer): string; var i: Integer; relleno: Integer; hexstr: string; Begin hexstr := Convert.ToString(hexint, 16); relleno := (lungh - hexstr.Length); for i:= 0 to relleno do hexstr := ('0' + hexstr); Result := hexstr; End;
END.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | If text loaded isn't RTF, .text property crashes. [modified] gerbilvomit | 11:06 6 Aug '08 |
|
 |
If "LoadRtfText()" is called with a plaintext string instead of RTF, accessing the ".text" property causes an "System.ArgumentOutOfRangeException: Index was out of range." exception.
The problem appears to be in "ConvertToTextAux()" in RtfTree.cs. In the case of plaintext, no child nodes are created, and "prim" is passed in as "-1". Because "-1 < 0", the for loop executes when it shouldn't and the "ChildNodes" array is mis-indexed.
My solution to this was to check that "prim >= 0" before entering the for loop. If "prim < 0", then I skip the for loop and just do the following: res.AppendLine(nprin.NodeKey);
Which just returns the text of the single plaintext node.
Hope that helps anyone else with the same problem.
modified on Wednesday, August 6, 2008 4:20 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | Merging RTF documents Olli Nissinen | 0:32 18 Jun '08 |
|
 |
Hi, is it possible to merge rtf documents to one document with this library without losing styles, tables etc. from the original documents. An example would be nice. Thank you in advance.
Olli
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, i've just finished to do this job. I've done new class to merge different RTF document. Here is just a small example. I've asked to project owner to include this my new class. Regards
// create main Rtf doc and insert into main doc rtf placeholder RtfDocument doc = new RtfDocument("..\\..\\SampleDoc\\RtfDoc.rtf"); RtfTextFormat textFmt = new RtfTextFormat(); textFmt.font = "Times New Roman"; textFmt.bold = true; doc.AddText("[TagTextRTF1] Test File with placeholder [TagTextRTF1], place holder will be replaced with RTF file. Second Place holder into same line [TagTextRTF2].", textFmt); textFmt.bold = false; textFmt.underline = true; textFmt.color = Color.Red; doc.AddText("Second text (RED underlined text) with following place holder [TagTextRTF2]", textFmt); doc.Close();
// create first to merge rtf doc doc = new RtfDocument("..\\..\\SampleDoc\\ToMerge1.rtf"); textFmt = new RtfTextFormat(); textFmt.font = "Georgia"; textFmt.color = Color.Blue; textFmt.bold = false; doc.AddText("(Hi, i'm RTF content of your 1st placeholder)", textFmt); doc.Close();
// create second to merge rtf doc doc = new RtfDocument("..\\..\\SampleDoc\\ToMerge2.rtf"); textFmt = new RtfTextFormat(); textFmt.font = "Verdana"; textFmt.color = Color.Green; textFmt.bold = false; doc.AddText("(Hi, i'm RTF content of your 2nd placeholder)", textFmt); doc.Close();
RtfMerger oTree = new RtfMerger(); oTree.MergeRtfDoc("..\\..\\SampleDoc\\RtfDoc.rtf", "\\[TagTextRTF(\\w+)\\]", new OtherRtfDocDelegate(manageDocToInsert), "..\\..\\SampleDoc\\Result.rtf", true, true); MessageBox.Show("Test ended!"); }
BoFabio
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
|
 |
|
|
 |
 | Issue with other charactersets! Member 3549314 | 1:04 28 May '08 |
|
 |
Found issue with other character sets (eg. Chinese/Japanese etc).
Sample rtf string. "{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\froman\fprq1\fcharset128 Arial Unicode MS;}{\f1\fswiss\fcharset0 Arial;}}{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\sb100\sa100\lang1033\f0\fs24\'82\'d0\'82\'e7\'82\'aa\'82\'c8\lang2057\f1\fs20\par}";
where '82\'d0\'82\'e7\'82\'aa\'82\'c8 is the text. But this is identified as Nodetype = control.
Thanks Sathish
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
 | Merge Codes beachbeamer | 16:55 15 May '08 |
|
|
 |
 | How I Can Find and Replace text ladakana | 22:11 3 Apr '08 |
|
 |
Hi, I would like find and replace text in rtf document, but I don't known how. Could you help me? RtfTree tree = new RtfTree(); tree.LoadRtfFile(sourceFileName); // //Here, I need find and replace string (for example Find: |<CustomerName>| a Replace: Intel) // tree.SaveRtf(destinationFileName);
Lada
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I'll try to update the library in two/three weeks.
In the new version you can define templates, merge documents, find/replace text...
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
|
 |
|
|
 |
 | HTML PQSIK | 13:12 24 Nov '07 |
|
 |
Hi, I have been looking at the help file and for the life of me I can't see how to convert rtf to html. Can someone give me a vb code example. Thanks
PQSIK
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |