Problem with header
Posted: Thu Jan 03, 2008 8:35 am
I have a problem with the size of my header.
Only the lowest part of my header is shown on the page (if the header is more than 5 lines of text).
It seems that the page does not allocate enough space for the full header - but how do I tell RVPrint how much space it should allocate for the header?
I'm using the onPagePrepaint because I need to make different headers for different pages.
My "insert header" code:
Relevant part of my dfm file:
Only the lowest part of my header is shown on the page (if the header is more than 5 lines of text).
It seems that the page does not allocate enough space for the full header - but how do I tell RVPrint how much space it should allocate for the header?
I'm using the onPagePrepaint because I need to make different headers for different pages.
My "insert header" code:
Code: Select all
procedure TfrmEditTemplate.CopyDoc(src, dst: TCustomRichView);
var Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
src.SaveRVFToStream(Stream, False);
Stream.Position := 0;
dst.LoadRVFFromStream(Stream);
Stream.Free;
end;
procedure TfrmEditTemplate.RVPrintPagePrepaint(
Sender: TRVPrint;
PageNo: Integer;
Canvas: TCanvas;
Preview: Boolean;
PageRect, PrintAreaRect: TRect);
begin
CopyDoc(rvHeader, rvhHeader.RichView);
rvhHeader.Init(Canvas, PrintAreaRect.Right-PrintAreaRect.Left);
rvhHeader.FormatNextPage(PrintAreaRect.Bottom-PrintAreaRect.Top);
rvhHeader.DrawPageAt(PrintAreaRect.Left, PrintAreaRect.Top-rvhHeader.GetLastPageHeight,
1, Canvas, False, rvhHeader.GetLastPageHeight);
end;
Code: Select all
object frmEditTemplate: TfrmEditTemplate
object rvHeader: TRichViewEdit
Left = 24
Top = 163
Width = 200
Height = 118
ReadOnly = False
ParentShowHint = False
PopupMenu = mnuSpell
ShowHint = False
TabOrder = 5
DoInPaletteMode = rvpaCreateCopies
MaxTextWidth = 783
MinTextWidth = 783
Options = [rvoAllowSelection, rvoScrollToEnd, rvoShowPageBreaks, rvoTagsArePChars, rvoAutoCopyText, rvoAutoCopyRVF, rvoAutoCopyImage, rvoAutoCopyRTF, rvoFormatInvalidate, rvoDblClickSelectsWord, rvoRClickDeselects, rvoShowItemHints]
RTFReadProperties.UnicodeMode = rvruMixed
RTFReadProperties.TextStyleMode = rvrsAddIfNeeded
RTFReadProperties.ParaStyleMode = rvrsAddIfNeeded
RVFOptions = [rvfoSavePicturesBody, rvfoSaveControlsBody, rvfoIgnoreUnknownPicFmt, rvfoIgnoreUnknownCtrls, rvfoConvUnknownStylesToZero, rvfoConvLargeImageIdxToZero, rvfoSaveBinary, rvfoSaveBack, rvfoLoadBack, rvfoSaveTextStyles, rvfoSaveParaStyles, rvfoSaveLayout, rvfoLoadLayout]
RVFParaStylesReadMode = rvf_sInsertMap
RVFTextStylesReadMode = rvf_sInsertMap
Style = rvsHeader
end
object rvsHeader: TRVStyle
TextStyles = <
item
StyleName = 'Normal text'
FontName = 'Arial'
end
item
StyleName = 'Code'
FontName = 'Arial'
Style = [fsBold]
BackColor = clGrayText
Protection = [rvprStyleProtect, rvprModifyProtect, rvprConcateProtect, rvprDoNotAutoSwitch]
end>
ParaStyles = <
item
StyleName = 'Paragraph Style'
Tabs = <>
end
item
StyleName = 'Centered'
Alignment = rvaCenter
Tabs = <>
end>
ListStyles = <
item
StyleName = 'Bullets'
Levels = <
item
LeftIndent = 24
Font.Height = -16
end>
LstID = 542175222
end>
SpacesInTab = -1
InvalidPicture.Data = {---snip---}
StyleTemplates = <>
Left = 31
Top = 198
end
object rvhHeader: TRVReportHelper
PreviewCorrection = True
RichView.BackgroundStyle = bsNoBitmap
RichView.BottomMargin = 0
RichView.Options = [rvoAllowSelection, rvoScrollToEnd, rvoShowPageBreaks, rvoTagsArePChars, rvoAutoCopyText, rvoAutoCopyRVF, rvoAutoCopyImage, rvoAutoCopyRTF, rvoFormatInvalidate, rvoDblClickSelectsWord, rvoRClickDeselects, rvoFastFormatting]
RichView.RTFReadProperties.TextStyleMode = rvrsAddIfNeeded
RichView.RTFReadProperties.ParaStyleMode = rvrsAddIfNeeded
RichView.RVFOptions = [rvfoSavePicturesBody, rvfoSaveControlsBody, rvfoSaveBinary, rvfoSaveTextStyles, rvfoSaveParaStyles, rvfoSaveDocProperties, rvfoLoadDocProperties]
RichView.Style = rvsHeader
RichView.TopMargin = 0
Left = 280
Top = 128
end
object RVPrint: TRVPrint
PreviewCorrection = True
LeftMarginMM = 20
RightMarginMM = 20
TopMarginMM = 20
BottomMarginMM = 20
OnPagePrepaint = RVPrintPagePrepaint
Left = 166
Top = 172
end
end