Hi all,
My client wants headers and footers to have a a different margin from the body. I am able to do it using input text but the input is not plain text, it will contain merge fields and are stored as HTML (See sample Input). The code workes perfectly if I enter in a plain string but entering in HTML it will indent the first <Div> but not subsequent <div>s. What happens is that the reader divides the HTML up into paragraphs and only indents the first as can be plainly seen in the sample output ( Note : input was cTestText for the header and cTestHTML for the footer). In particular look at line 4 of the rtf output and notice the indents have been reset.
How do I make the indent continue thoughout the header/footer?
Thanks in advance
sample Input
ZitatAlles anzeigen
cTestText =
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test ';cTestHTML =
'<html>' +
'<body>' +
'<div>' +
'<b>** Right **</b>' +
'</div>' +
'<div>' +
'<b>** Left **</b>' +
'</div>' +
'<div>' +
'<b>** Center **</b>' +
'</div></body></html>';
Delphi Code IndentedHeaderFooter
ZitatAlles anzeigenprocedure TForm1.IndentedHeaderFooter(AWP: TWPRichText; Kind: TWPPagePropertyKind;
AStr: string);
var
par: TParagraph;
I: Integer;
begin
begin
AWP.HeaderFooter.Get(Kind, wpraOnAllPages).Clear(true);
par := AWP.HeaderFooter.Get(Kind, wpraOnAllPages).FirstPar;
AWP.Header.MarginHeader := 100;
AWP.Header.MarginFooter := 100;
par.ClearText;
AWP.HeaderFooter.Get(Kind, wpraOnAllPages).WorkOnText := True;
AWP.SelectionAsString := AStr;
SetIndents(AWP.HeaderFooter.Get(Kind, wpraOnAllPages).FirstPar, -editMovementMargins.value);
AWP.ReformatAll(True, True);
end;
end;procedure TForm1.SetIndents(par: TParagraph; AIndent: integer);
var
I: Integer;
begin
par.indentleft := AIndent;
par.indentright := AIndent;
for I := 0 to par.ChildrenCount - 1 do
SetIndents(par.Children[I], AIndent);
end;
SAMPLE OUTPUT (RTF)
ZitatAlles anzeigen{{{\header{\li-800\ri-800\plain\fs22 Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test \par
}}
{\footer{\pard\plain\li-800\ri-800\plain\fs22\b ** Right **\par
\li0\ri0\plain\fs22\b ** Left **\par
\qc\plain\fs22\b ** Center **\par
}}
\pard\plain\plain\f0\fs22 Page 1\par
\pard\plain\plain\f0\fs22\par
\plain\f0\fs22 XXXX\par
}}