In ScaleRichView1, I load some sale data (net, gross, customer info, etc). I also have a custom onPaintPage event to display some header and footers.
Code: Select all
var
H : Integer;
Text: String;
begin
inherited;
if Prepaint then
Exit; // *** EXIT RIGHT HERE ****
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clRed;
Canvas.Font.Assign( ScaleRicheView1 .RichViewEdit.Style.TextStyles[0]) ;
// Drawing header
H := ScaleRicheView1 .TopMargin100Pix;
Text := 'Page ' + IntToStr(PageNo);
Canvas.FillRect( Rect( PageRect.Left, PageRect.Top, PageRect.Right, PageRect.Top + H ) );
Canvas.TextOut( ((PageRect.Left + PageRect.Right - Canvas.TextWidth(Text)) div 2),
PageRect.Top+H div 2, Text );
// Drawing footer
H := ScaleRicheView1 .BottomMargin100Pix;
Text := 'Sample Footer';
Canvas.FillRect( Rect(PageRect.Left, PageRect.Bottom - H, PageRect.Right, PageRect.Bottom ) );
Canvas.TextOut( ((PageRect.Left + PageRect.Right - Canvas.TextWidth(Text)) div 2),
PageRect.Bottom - H div 2, Text);
end;
Code: Select all
procedure AppendSale;
var
Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
try
ScaleRichView1.RichViewEdit.SaveRVFToStream( Stream, False {ASelectionOnly} );
Stream.Position := 0;
ScaleRichView2.RichViewEdit.InsertRVFFromStream( Stream, ScaleRichView2.RichViewEdit.ItemCount );
ScaleRichView2.Format;
finally
FreeandNil( Stream );
end;
end;
procedure DisplaySales;
var
SaleIndex: Integer;
begin
for SaleIndex := 0 to Sales.Count -1 do
begin
// ... {first load ScaleRichView1 info/data here}, then
AppendSale;
end;
end;
The idea in the end is to have 1 ScaleRichView control that would display a page # footer like (assuming we have 2 sales with 3 pages each):
* Sale 1 *
Page 1 of 3
Page 2 of 3
Page 3 of 3
* Sale 2 *
Page 1 of 3
Page 2 of 3
Page 3 of 3
How can I do this?
Please advise,
Richard