Font is not taken when inserting into RichEdits in HTML format

General TRichView support forum. Please post your questions here
Post Reply
tomr
Posts: 21
Joined: Wed Dec 09, 2020 9:36 am

Font is not taken when inserting into RichEdits in HTML format

Post by tomr »

Hello RichView Suport,

we have tested your components [CompiledDemos\ActionTests\ScaleRichView\ActionTestUni.exe] from this link https://www.trichview.com/rvfiles/TRich ... sSetup.exe. There occured one problem in inserting a html text from a mail. The font in the mail was ARIAL. After inserting the text into the RichEdit via function „Paste Special…“ in HMTL format the font of the text in the RichEdit was „TimesNewRoman“.
RichView_html_format.jpg
RichView_html_format.jpg (111.18 KiB) Viewed 22014 times
Are you aware of this effect and is it possible to keep the font of the original HMTL text in the RichView?

Best Regards
Nedeljka
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Font is not taken when inserting into RichEdits in HTML format

Post by Sergey Tkachenko »

Hello,

The compiled demo uses a basic HTML importer (TrvHtmlImporter component) that supports only basic HTML formatting; it does not support CSS.
There is an alternative HTML importer component producing much better results, TrvHtmlViewImporter.
But it requires additional third-party component, THMLViewer.
It is free with source code. You can download it here: https://github.com/BerndGabriel/HtmlViewer
After installing its packages (for new versions of Delphi, they are named FrameViewer.dpk (runtime) and dclFrameViewer.dpk (designtime)), recompile TRichView packages (use "Install TRichView in Delphi IDE" shortcut in Windows Start menu).
TrvHtmlViewImporter must be installed.

To use it in RichViewActions, open one of ActionTest projects. Place THTMLViewer on a main form, make it hidden. Place TrvHtmlViewImporter on the same form. Assign RVAControlPanel1.HTMLComponent = rvHtmlViewImporter1, rvHtmlViewImporter.HTMLViewer = HTMLViewer1.
That's all. Now open, insert file, and paste actions use this importer.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Font is not taken when inserting into RichEdits in HTML format

Post by jgkoehn »

Greetings Sergey,
Would you still recommend this HTMLViewer with Delphi 11? We are pasting from HTML into TRichViewEdit but are not getting color. Is this perhaps why? (Even using Paste Special > Html)
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Font is not taken when inserting into RichEdits in HTML format

Post by Sergey Tkachenko »

Yes, HTML import using THTMLViewer + TrvHtmlViewImporter is still the best option.
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: Font is not taken when inserting into RichEdits in HTML format

Post by edwinyzh »

Any possibility of a "TrvHCLImporter" that integrates with http://delphihtmlcomponents.com/?

I assume it can produce better import result.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Font is not taken when inserting into RichEdits in HTML format

Post by Sergey Tkachenko »

No, I plan to implement native HTML import, without third-party components.
Currently, this is the main priority (not counting FMX-related features)
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: Font is not taken when inserting into RichEdits in HTML format

Post by jgkoehn »

Will the html importer work with external css? Also will it be a tag style < > importer?
We are using the older version and need to update to accommodate the external css. (We have done a lot of internal modifications to the previous html importer to support some of our needs.)

I added regex support before the import so we can modify portions of the html as we need and so we can add our own specialized tags.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Font is not taken when inserting into RichEdits in HTML format

Post by Sergey Tkachenko »

Yes, native HTML import code will support all types of CSS, internal, external and inline.
It is almost ready but still too buggy to be released.
I'll complete port to Android (soon) and return to HTML import.
Post Reply