Hi,
I am evaluating a demo version of trichedit. I have an import function that allows the user to import a .mht file, which then extracts the .mht into html with sub dirs for images.
When I programmatically open the html file in trichedit (after the import is complete) the images do not load. However, If I then manually use the Open dialog using richviewactions, the html file loads fine and the images are displayed correctly.
I am using the same code for both operations (both import and open):
----------------------------BEGIN CODE SNIPPET-----------------------------
function TfrmMain.LoadHTMLFile(aHTMLFileName : string; aRichViewEdit : TCustomRichViewEdit) : boolean;
var
Stream : TFileStream;
s : String;
begin
try
Stream := TFileStream.Create(aHTMLFileName, fmOpenRead);
try
SetLength(s, Stream.Size);
Stream.ReadBuffer(PChar(s)^, Length(s));
finally
Stream.Free;
end;
RvHtmlImporter1.RichView := aRichViewEdit;
RvHtmlImporter1.LoadHtml(s);
fLastOpenedFile := aHTMLFileName;
result := True;
except;
result := False;
end;
end
------------------------END CODE SNIPPET----------------------------------
Can you help me figure out why the file is not rendering after an import, but does render correctly after an open?
Thank you in advance,
Shaune
Previewing html
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
If paths to images (in <img>) are relative to the path where this HTML file is located, they cannot be loaded unless you specify a base path:
Code: Select all
RvHtmlImporter1.BasePath := ExtractFilePath(aHTMLFileName);
try
RvHtmlImporter1.LoadHtml(s);
finally
RvHtmlImporter1.BasePath := '';
end;
html importer
Hi,
Thank you, that works. The HTML now displays with the correct images. However, I still have the following problems:
1. The background is set in the .html, but when I open the html using the htmlimporter, the background is not set.
2. After opening an html file, I first need to resize my main form before the .html renders in the richview control.
3. The mht files that I need to inport almost always uses an embedded stylesheet (CSS). Is there any way that I can get the html to render correctly using the htmlimporter?
Thank you in advance.
Thank you, that works. The HTML now displays with the correct images. However, I still have the following problems:
1. The background is set in the .html, but when I open the html using the htmlimporter, the background is not set.
2. After opening an html file, I first need to resize my main form before the .html renders in the richview control.
3. The mht files that I need to inport almost always uses an embedded stylesheet (CSS). Is there any way that I can get the html to render correctly using the htmlimporter?
Thank you in advance.
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
1. How the background is specified?
2. Call aRichViewEdit.Format after loading
3. No, CSS is not supported. More info: http://www.trichview.com/forums/viewtopic.php?t=359
2. Call aRichViewEdit.Format after loading
3. No, CSS is not supported. More info: http://www.trichview.com/forums/viewtopic.php?t=359
Previewing html
Hi,
I think I need to clear some things up.
I am trying to use Trichedit as an html editor. The user can create a new document and edit it, then save it as .html (using HTMLSaveEx - which creates .html with in-line CSS).
Problem 1: Document Background:
1. User creates a new document and sets the background image as stretched.
2. After editing the document, save as .html (uses SaveHTMLex).
3. Re-open the html in tRichedit. The background is no longer stretched, now is "centered" by default. If I inspect the .html document, the style is set as follows:
========BEGIN HTML IN-LINE STYLE===========
body {
margin: 5px 5px 5px 5px;
background-color: #ffffff;
background-image: url("1.gif");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center center;
}===========END HTML IN-LINE STYLE=========
So, the background position is saved incorrectly with SaveHTMLEx.
Problem 2: Opening saved .html
RichView.Format seems to work.
Thank you,
I think I need to clear some things up.
I am trying to use Trichedit as an html editor. The user can create a new document and edit it, then save it as .html (using HTMLSaveEx - which creates .html with in-line CSS).
Problem 1: Document Background:
1. User creates a new document and sets the background image as stretched.
2. After editing the document, save as .html (uses SaveHTMLex).
3. Re-open the html in tRichedit. The background is no longer stretched, now is "centered" by default. If I inspect the .html document, the style is set as follows:
========BEGIN HTML IN-LINE STYLE===========
body {
margin: 5px 5px 5px 5px;
background-color: #ffffff;
background-image: url("1.gif");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center center;
}===========END HTML IN-LINE STYLE=========
So, the background position is saved incorrectly with SaveHTMLEx.
Problem 2: Opening saved .html
RichView.Format seems to work.
Thank you,
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
1) Stretched images are exported as centered because HTML does not support stretched background images.
2) Reading CSS saved by SaveHTMLEx is a newest feature of RvHtmlImporter (and it was not implemented by me). May be it is still not perfect, and background is not read. I'll try verify it this weekend.
2) Reading CSS saved by SaveHTMLEx is a newest feature of RvHtmlImporter (and it was not implemented by me). May be it is still not perfect, and background is not read. I'll try verify it this weekend.