Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RTF TO HTML. how to?

1,364 views
Skip to first unread message

Viggo Jamne

unread,
Apr 29, 2003, 11:53:55 AM4/29/03
to
Hi all:)

I have Delphi 7 Pro.

I have tried to download some code from the net, but none of them works.

I need to convert RTF from TRichEdit control to HTML.

Is there any good sample out there?

I dont need any shareware stuff.

Thanks in advanced

Best regards
Viggo Jamne
Norway


Peter Below (TeamB)

unread,
Apr 29, 2003, 4:55:06 PM4/29/03
to
In article <3eae...@newsgroups.borland.com>, Viggo Jamne wrote:
> I have Delphi 7 Pro.
> I have tried to download some code from the net, but none of them works.
> I need to convert RTF from TRichEdit control to HTML.
> Is there any good sample out there?

I have only these two URLs on file on the subject. Never looked at them
myself, though.

Converting RTF to HTML
http://meteortech.com/ScholarSoft/delphi/
http://www55.pair.com/betasoft/indexp1.html#12

If you have MS Word installed you can perhaps use it via OLE automation to
perform the conversion.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Alejandro Castro

unread,
Apr 29, 2003, 10:28:42 PM4/29/03
to
Goto
http://www.delphi-jedi.org/

They have a component: JvRichEditToHtml

"Viggo Jamne" <fi...@norprog.no> escribió en el mensaje
news:3eae...@newsgroups.borland.com...

Viggo Jamne

unread,
Apr 30, 2003, 6:26:50 AM4/30/03
to
Thanks :)

But it donsent work to well with bullets and numbers.
I have to go into the code and see if i can figure it out.

So, none of the source out there have worked for me jet.

Is there a sample for HTML to RTF somewhere do you think?

Best Regards
Viggo Jamne

"Alejandro Castro" <alej...@alfra.info> wrote in message
news:3eaf3586$1...@newsgroups.borland.com...

Alejandro Castro

unread,
Apr 30, 2003, 10:54:37 AM4/30/03
to
The component has a problem when you have a #0 (chraracter(0)) inserted in
the RichText, I fixed the problem , the function is

function TJvRichEditToHtml.ConvertToHtmlstringList(Value: TRichEdit):
TStringList;
var
i, j: Integer;
datt, att, currat: TFont;
dpara, para, currpara: TJvParaAttributes;
st: string;
FEnd: string;
begin
Value.Lines.BeginUpdate;
Result := TStringList.Create;
Result.Add(RC_Html1);
Result.Add(RC_Html7);
Result.Add(RC_Html3);

datt := TFont.Create;
att := TFont.Create;
currat := TFont.Create;

dpara.Alignment := taLeftJustify;
dpara.Numbering := nsNone;
currpara.Alignment := dpara.Alignment;
currpara.Numbering := dpara.Numbering;
FendPara := '';

datt.Assign(Value.DefAttributes);
Result.Add(AttToHtml(datt));
FEnd := FEndSection;

// k := 0;
Currat.Assign(datt);
FEndSection := '';
st:='';
i:=0;
j:=0;
while i<=Length(Value.Text) - 1 do begin
if Value.Text[i]=#0 then begin
inc(j);
end
else begin
if Value.Text[i]=#13 then begin
if Value.Text[i+1]=#10 then begin
st:=st+RC_Html4;
Result.Add(st);
Application.ProcessMessages;
st:='';
inc(i);
end;
end
else begin
Value.SelStart := i-j;
Value.SelLength := 1;
att.Assign(Value.SelAttributes);
para.Alignment := Value.Paragraph.Alignment;
para.Numbering := Value.Paragraph.Numbering;

if Diff(att, currat) then begin
st := st + FEndSection;
currat.Assign(att);
st := st + AttToHtml(att);
end;

if DiffPara(para, currpara) then begin
st := st + FEndPara;
currpara.Alignment := para.Alignment;
currpara.Numbering := para.Numbering;
st := st + ParaToHtml(para);
end;
st := st + FCharToH.CharToHtml(Value.Text[i]);
end;
end;
inc(i);
end;
if st<>'' then
Result.Add(st);

datt.Free;
att.Free;
currat.Free;

Result.Add(FEnd);
Result.Add(RC_Html5);
Result.Add(RC_Html6);
Value.Lines.EndUpdate;
end;

"Viggo Jamne" <fi...@norprog.no> escribió en el mensaje

news:3eaf...@newsgroups.borland.com...

Viggo Jamne

unread,
Apr 30, 2003, 7:15:50 PM4/30/03
to
Thanks :)

Your new function didn't work either.
I only got the first bullet. The <LI> parameter was just present on the
first bullet in the HTML code.

I didn't fint then FCharToH Record or class, so i changed it back to
orginal.

I changed a bit on the function.
Now it works for me :)

Here is the canges.

function TJvRichEditToHtml.ConvertToHtmlstringList(Value: TRichEdit):
TStringList;
var
i, j: Integer;
datt, att, currat: TFont;
dpara, para, currpara: TJvParaAttributes;
st: string;
FEnd: string;

Bullets : Boolean; file://Changes for bullets to work .... Viggo
Jamne(01.05.2003)

file://Changes for bullets to work .... Viggo Jamne(01.05.2003)
if st = '' then
if (Bullets) then
st := st + RC_LeftIndent;
file://....Changes end

if Diff(att, currat) then begin
st := st + FEndSection;
currat.Assign(att);
st := st + AttToHtml(att);
end;

if DiffPara(para, currpara) then begin

file://Changes for bullets to work .... Viggo Jamne(01.05.2003)
if para.Numbering <> nsNone then
Bullets := True
else
Bullets := False;
file://....Changes end

st := st + FEndPara;
currpara.Alignment := para.Alignment;
currpara.Numbering := para.Numbering;
st := st + ParaToHtml(para);
end;

st := st + CharToHtml(Value.Text[i]);


end;
end;
inc(i);
end;
if st<>'' then
Result.Add(st);

datt.Free;
att.Free;
currat.Free;

Result.Add(FEnd);
Result.Add(RC_Html5);
Result.Add(RC_Html6);
Value.Lines.EndUpdate;
end;

"Alejandro Castro" <alej...@alfra.info> wrote in message
news:3eaf...@newsgroups.borland.com...

Viggo Jamne

unread,
May 1, 2003, 9:46:38 PM5/1/03
to
I didn't think of the // when i was commenting code.
So, delete the "file" word where you see something that look like a link.
Sorry for this guys :)

"Viggo Jamne" <fi...@norprog.no> wrote in message
news:3eb0...@newsgroups.borland.com...

0 new messages