XHtml to stream export
XHtml to stream export
Hi,
Is there support for exporting xhtml into a stream so I can stream it directly into an embeddedWB from EuroMind without saving to disc first?
Is there support for exporting xhtml into a stream so I can stream it directly into an embeddedWB from EuroMind without saving to disc first?
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Thanks
For people interested the following code works like charm:
For people interested the following code works like charm:
Code: Select all
procedure T_TaakEditor.DoPreview(rve: TRichViewEdit);
var
ms : TMemoryStream;
begin
ms := TMemoryStream.Create;
rve.SaveHTMLToStreamEx(ms,
ChangeFileExt(Application.ExeName, '.xhtml'),
'A Title', '', '', '', '',
[rvsoUTF8, rvsoXHTML]);
ms.Seek(0, soFromBeginning);
emBeddedWB1.LoadFromStream(ms);
end;
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hi,
Perhaps i need to clarify, i dropped an image from the file system into a TRichViewEdit and call the streaming function.
The output is:
I did some digging and found that OnHtmlSaveImage is called but for it to work i need to manually save the Image but can't get the Filename from the ItemNo supplied.
I Also found that setting doDefault to true saves the image to disc (as i want to) but also resets the filename written into the html generated.
Perhaps i need to clarify, i dropped an image from the file system into a TRichViewEdit and call the streaming function.
The output is:
Code: Select all
<img alt="" hspace="1" vspace="1" src="Pim.xhtml13.jpg" />
I did some digging and found that OnHtmlSaveImage is called but for it to work i need to manually save the Image but can't get the Filename from the ItemNo supplied.
I Also found that setting doDefault to true saves the image to disc (as i want to) but also resets the filename written into the html generated.
Preview content in an EmbeddedWB including disc based Images
Hi,
Finnaly figured it out. The trick lies in the OnSaveImage Event but needs to duplicate some code from TCustomRVData.DoSavePicture.
Only minor flaw is that the OverrideFileNames parameter isn't available so I had to set it to false (but as the calling program passes it in, it's also known inside the eventhandler).
Result is an image save to disc and a correct file:/// type url in the generated xhtml.
The OnSaveImage2 eventhandler:
And the calling routine that previews TRichViewEdit content in an EmbeddedWB including disc based images:
Finnaly figured it out. The trick lies in the OnSaveImage Event but needs to duplicate some code from TCustomRVData.DoSavePicture.
Only minor flaw is that the OverrideFileNames parameter isn't available so I had to set it to false (but as the calling program passes it in, it's also known inside the eventhandler).
Result is an image save to disc and a correct file:/// type url in the generated xhtml.
The OnSaveImage2 eventhandler:
Code: Select all
procedure TXHtmlEditFrame.RichViewEdit1SaveImage2(Sender: TCustomRichView;
Graphic: TGraphic; SaveFormat: TRVSaveFormat; const Path,
ImagePrefix: string; var ImageSaveNo: Integer; var Location: string;
var DoDefault: Boolean);
var
ext : string;
fn : string;
begin
if SaveFormat = rvsfHTML then
begin
ext := '.jpg';
if RV_IsHTMLGraphicFormat(Graphic) then
ext := '.' + GraphicExtension(TGraphicClass(Graphic.ClassType));
end
else
ext := '.bmp';
fn := Sender.RVData.GetNextFileName(ImagePrefix, Path, Ext, ImageSaveNo, false); //no OverrideFileNames
if (SaveFormat = rvsfHTML) and
((Graphic is TJpegImage) or RV_IsHTMLGraphicFormat(Graphic)) then
Graphic.SaveToFile(fn);
//Sample: src="file:///C:/Bureaublad/Joe_s_Garage.gif"
Location := 'File:///' + StringReplace(fn, '\', '//', [rfReplaceAll]);
DoDefault := False;
end;
Code: Select all
procedure T_TaakEditor.DoPreview(rve: TRichViewEdit);
var
ms : TMemoryStream;
begin
ms := TMemoryStream.Create;
rve.RVData.Flags := rve.RVData.Flags + [rvflRoot];
rve.SaveHTMLToStreamEx(ms,
ExtractFilePath(Application.ExeName),
'A Title', '', '', '', '',
[rvsoUTF8, rvsoXHTML]);
ms.Seek(0, soFromBeginning);
Preview.LoadFromStream(ms);
end;
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hi,
My excuses for mixing them up again. I tend to treat everything with a url as a hyperlink.
But is it possible to change the routines a bit so you can save the image more easily by calling the code already present in TRichView? I find copying peices code to archieve a minor enhancement awkward as the copied piece may change for next releases of a library like TRIchView.
My excuses for mixing them up again. I tend to treat everything with a url as a hyperlink.
But is it possible to change the routines a bit so you can save the image more easily by calling the code already present in TRichView? I find copying peices code to archieve a minor enhancement awkward as the copied piece may change for next releases of a library like TRIchView.
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Code: Select all
procedure TForm3.RichViewEdit1SaveImage2(Sender: TCustomRichView;
Graphic: TGraphic; SaveFormat: TRVSaveFormat; const Path,
ImagePrefix: String; var ImageSaveNo: Integer; var Location: String;
var DoDefault: Boolean);
begin
Location := Sender.RVData.SavePicture(SaveFormat, ImagePrefix, Path, ImageSaveNo, True,
clWhite, Graphic);
Location := 'file://' + StringReplace(Path+Location, '\', '/', [rfReplaceAll]);
DoDefault := False;
end;
Last edited by Sergey Tkachenko on Fri Sep 23, 2005 9:23 am, edited 1 time in total.
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: