Hi Sergey,
What's the best approach to insert copied html (hyperlinks, images, tables, etc) from a web-page into a TRichView. In some other thread you mentioned "TRvHtmlImporter or TrvHtmlViewImporter (better)"? Any good demo?
Thx,
Paste html, best method? Demo?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Both importers have LoadFromClipboard method. They replace existing content of TRichView and load HTML from the Clipboard.
If you need a normal pasting operation, then use OnPaste event: load HTML from the Clipboard to a hidden TRichView, save it to TMemoryStream (SaveRVFToStream) and insert in the target editor (InsertRVFFromStreamEd).
In RichViewActions, there is a function PasteHTML (RichViewActions.pas) that does this work. It can work both with TRvHtmlImporter and TrvHtmlViewImporter, depending on the compiler defines.
If you do not use RichViewActions, you can create HTML pasting procedure basing on this procedure.
If you use RichViewActions, it pastes it automatically, if you compile them with support of importers, see
http://www.trichview.com/help-actions/r ... porter.htm
http://www.trichview.com/help-actions/r ... porter.htm
As it was noticed, TrvHtmlViewImporter provides better results.
If you need a normal pasting operation, then use OnPaste event: load HTML from the Clipboard to a hidden TRichView, save it to TMemoryStream (SaveRVFToStream) and insert in the target editor (InsertRVFFromStreamEd).
In RichViewActions, there is a function PasteHTML (RichViewActions.pas) that does this work. It can work both with TRvHtmlImporter and TrvHtmlViewImporter, depending on the compiler defines.
If you do not use RichViewActions, you can create HTML pasting procedure basing on this procedure.
If you use RichViewActions, it pastes it automatically, if you compile them with support of importers, see
http://www.trichview.com/help-actions/r ... porter.htm
http://www.trichview.com/help-actions/r ... porter.htm
As it was noticed, TrvHtmlViewImporter provides better results.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Yes, usually links to images are on remote servers, and you need to download them.
If RichViewActions are compiled with the support of Indy or CleverComponents:
http://www.trichview.com/help-actions/indy.htm
http://www.trichview.com/help-actions/c ... onents.htm
they do it automatically.
Otherwise, you need to implement downloading yourself, in TRichView.OnImportPicture event.
An example of implementation can be found in RichViewActions.pas, TRVAControlPanel.DoImportPicture method.
It uses FDownloadedPictures: TStringList to avoid downloading the same picture multiple times when importing the same HTML .
It saves downloaded pictures in temporal files, because VCL does not have a public method returning a graphic class by file extension, so we need a workaround with files.
If RichViewActions are compiled with the support of Indy or CleverComponents:
http://www.trichview.com/help-actions/indy.htm
http://www.trichview.com/help-actions/c ... onents.htm
they do it automatically.
Otherwise, you need to implement downloading yourself, in TRichView.OnImportPicture event.
An example of implementation can be found in RichViewActions.pas, TRVAControlPanel.DoImportPicture method.
It uses FDownloadedPictures: TStringList to avoid downloading the same picture multiple times when importing the same HTML .
It saves downloaded pictures in temporal files, because VCL does not have a public method returning a graphic class by file extension, so we need a workaround with files.