Page breaks in HTML
Posted: Sat Nov 25, 2017 9:59 am
Hello, Sergey!
Saving 2 pages to html, having following code below
it has link to css style style="page-break-before: always;" but no style in code...
so when loading back to srichview - all content on one page - could you advice something?
save html
load html
Questions
1) how to split correctly on pages when save load from html?
2) how to save header and footer of each page and then load it? For the moment i just doing sometging like this
but not sure it is correct
Thanks in advance!
Saving 2 pages to html, having following code below
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
body {
margin: 94px 57px 94px 132px;
background-color: #ffffff;
}
/* ========== Text Styles ========== */
hr { color: #000000}
body, table, span.rvts0 /* Normal text */
{
font-size: 10pt;
font-family: 'Arial', 'Helvetica', sans-serif;
font-style: normal;
font-weight: normal;
color: #000000;
text-decoration: none;
}
span.rvts1 /* Heading */
{
font-weight: bold;
color: #0000ff;
}
span.rvts2 /* Subheading */
{
font-weight: bold;
color: #000080;
}
span.rvts3 /* Keywords */
{
font-style: italic;
color: #800000;
}
a.rvts4, span.rvts4 /* Jump 1 */
{
color: #008000;
text-decoration: underline;
}
a.rvts5, span.rvts5 /* Jump 2 */
{
color: #008000;
text-decoration: underline;
}
span.rvts6
{
color: #000000;
}
span.rvts7
{
font-size: 22pt;
font-family: 'calibri';
color: #000000;
}
span.rvts8
{
font-size: 14pt;
color: #000000;
}
span.rvts9
{
font-size: 14pt;
color: #969696;
}
span.rvts10
{
color: #808080;
}
span.rvts11
{
font-size: 16pt;
color: #333333;
}
span.rvts12
{
color: #333333;
}
/* ========== Para Styles ========== */
p,ul,ol /* Paragraph Style */
{
text-align: left;
text-indent: 0px;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
}
.rvps1 /* Centered */
{
text-align: center;
}
--></style>
</head>
<body>
<p><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts7>Отчет по элементу события пользователя</span></p>
<p class=rvps1><span class=rvts8><br></span></p>
<p class=rvps1><span class=rvts11>{{0}}</span></p>
<p class=rvps1><span class=rvts9><br></span></p>
<p class=rvps1><span class=rvts11>{{1}}</span></p>
<p class=rvps1><span class=rvts6><br></span></p>
<p class=rvps1><span class=rvts12>{{2}}</span></p>
<p class=rvps1 style="page-break-before: always;"><span class=rvts12>123</span></p>
<p class=rvps1><span class=rvts10><br></span></p>
<p class=rvps1><span class=rvts6><br></span></p>
</body></html>
so when loading back to srichview - all content on one page - could you advice something?
save html
Code: Select all
procedure TReportTemplatesConstructor.SaveHTMLContent();
begin
with qSelectReportTemplate do
begin
try
connection := MainModule.FDConnection;
CachedUpdates := true;
Params.ParamValues['id'] := FReportTemplateID;
Disconnect();
Open();
trWrite.Connection := MainModule.FDConnection;
trWrite.StartTransaction();
Edit();
FieldByName('htmlContentHeader').AsString := getHtmlFromRVE(SRichViewEdit.RVHeader);
FieldByName('htmlContentBody').AsString := getHtmlFromRVE(SRichViewEdit.RichViewEdit);
FieldByName('htmlContentFooter').AsString := getHtmlFromRVE(SRichViewEdit.RVFooter);
if ApplyUpdates <> 0 then
raise Exception.Create(RowError.Message);
trWrite.Commit();
//Close();
except
on E: Exception do
raise Exception.Create('Error Message ' + E.Message);
end;
end;
end;
Code: Select all
procedure TReportViewerForm.LoadHTMLContent(AHtml: string);
var
tempDir: string;
randomFilePath: string;
clientTempDir: string;
i: Integer;
begin
try
tempDir := ExtractFilePath(Application.ExeName) + 'files\temp';
TDirectory.CreateDirectory(tempDir);
randomFilePath := tempDir + '\' + inttostr(Random(1000000)) + '.html';
TFile.AppendAllText(randomFilePath, AHtml, TEncoding.UTF8);
RVAControlPanel.InitImportPictures(nil, nil);
SRichViewEdit.ActiveEditor.OnImportPicture := RVAControlPanel.DoImportPicture;
RVHTMLViewImporter.LoadFromFile(randomFilePath, SRichViewEdit.ActiveEditor);
RVAControlPanel.DoneImportPictures;
SRichViewEdit.ActiveEditor.OnImportPicture := nil;
SRichViewEdit.ActiveEditor.FormatAll();
finally
if TFile.Exists(randomFilePath) then
TFile.Delete(randomFilePath);
end;
// normalizing table borders
for i := 0 to SRichViewEdit.ActiveEditor.ItemCount - 1 do
begin
if ((SRichViewEdit.ActiveEditor.GetItem(i).StyleNo = -60)) then
begin
SRichViewEdit.ActiveEditor.SetItemTag(i, i.ToString());
FTableListSL.Add(i.ToString());
NormalizeTableBorders(i);
end;
end;
end;
1) how to split correctly on pages when save load from html?
2) how to save header and footer of each page and then load it? For the moment i just doing sometging like this
Code: Select all
FieldByName('htmlContentHeader').AsString := getHtmlFromRVE(SRichViewEdit.RVHeader);
Thanks in advance!