Recent

Author Topic: Converting TRichMemo content to HTML  (Read 756 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Converting TRichMemo content to HTML
« on: June 23, 2022, 04:08:57 am »
Hasn't anybody know such a feature?   Supporting only bold, underline, and italic is sufficient.

Currently I'm using TMemo to get text input, and my web-server uses the content as part of HTML page. I copy a paragraph from word processor, e.g. MS-Word, which contain bolded words. But when I copy it into TMemo then all the font style definitions are gone.  If I'd like to make some words bold, I have to input <b> and </b> manually.

So I'm considering using TRichMemo instead of TMemo. I'm looking for a simple way.

I tested copying MS-Word paragraph into both TMemo and TRichMemo. In the attached image, the left one is TRichMemo, and the right one is TMemo.
« Last Edit: June 23, 2022, 04:17:52 am by egsuh »

paweld

  • Hero Member
  • *****
  • Posts: 970
Best regards / Pozdrawiam
paweld

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Re: Converting TRichMemo content to HTML
« Reply #2 on: June 27, 2022, 05:34:52 am »
Thank you very much, paweld.  I'll review the codes.

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Converting TRichMemo content to HTML
« Reply #3 on: June 27, 2022, 10:50:33 am »
There is a better one, written by Marco Cantu, that compiles without change in {$mode delphi}.
The link above is to code that might have been useful for Delphi 1, but shows its age.
The code by Marco is also old, but much better designed and is still relevant.
Specialize a type, not a var.

paweld

  • Hero Member
  • *****
  • Posts: 970
Re: Converting TRichMemo content to HTML
« Reply #4 on: June 27, 2022, 12:00:24 pm »
@Thaddy: I checked the code you shared in one of the threads, but it doesn't work "out of the box".
I also had the code shared by ruthjes@******.nl in my archive, which works, but unfortunately has a problem with UTF-8 characters.
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018