Past from TWebbrowser into TRichViewEdit

General TRichView support forum. Please post your questions here
Post Reply
randydom
Posts: 1
Joined: Sat Nov 16, 2019 6:56 am

Past from TWebbrowser into TRichViewEdit

Post by randydom »

Hello , i've copied an element contents from a Webbrowser using A.outerText .
so my clipboard content is ( as an example ) :

Code: Select all

<span ID=123>hello</span>
 <img src="smiley.gif"> 
So please how could i past that directly into my TRichViewEdit with the correct format i mean with no HTML format ?

Thank you .
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Past from TWebbrowser into TRichViewEdit

Post by Sergey Tkachenko »

Do you mean how to paste HTML format from the Clipboard?

When document is copied to the Clipboard in HTML format, not only HTML code but also a special header is copied.
For example:

Code: Select all

Version:1.0
StartHTML:000000173
EndHTML:000000859
StartFragment:000000205
EndFragment:000000827
SourceURL:https://www.trichview.com/forums/posting.php?mode=reply&f=2&t=9752
<html><body><!--StartFragment--><a href="https://www.trichview.com/forums/viewtopic.php?f=2&t=9752" style="background-color: transparent; color: rgb(211, 17, 65); direction: ltr; display: inline-block; font-family: &quot;Trebuchet MS&quot;,Arial,Helvetica,sans-serif; font-size: 20px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; outline-color: invert; outline-style: none; outline-width: 0px; text-align: left; text-decoration: underline; text-indent: 0px; text-transform: none; unicode-bidi: embed; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">TRichViewEdit</a><!--EndFragment--></body></html> 
It is important, because header contains the source URL, it is necessary to import images (otherwise, in your example, there is not way to know where is "smile.gif" located).

The both HTML importer components (TrvHtmlImporter and TrvHtmlViewImporter) can load HTML from the Clipboard: they have LoadFromClipboard method. These methods do not insert the Clipboard content in the caret position; instead they load it into TRichView (i.e. replace the existing document).
But you can load it in a temporal TRichView, copy its content to a stream (SaveRVFToStream) and then paste in the main editor (insertRVFFromStreamEd). You can use its OnPaste event for this.

If you use RichViewAction, they do HTML pasting automatically. Just assign TrvHTMLViewImporter (recommended) or TrvHtmlImporter component to TRVAControlPanel.HTMLComponent.
Post Reply