Created at runtime: MasterData runs off page and PageFooter overlaps
Hello.
I am creating a Fast Report at runtime, entirely from code. The problem is, the data runs off the page (pagesize being A4, didn't set it specifically), or rather it clips the last line printed on page. Report is transported to PDF, but doing Report.ShowReport(...) it also runs off the page. Additionally, if i add a PageFooter to the report, it does not resize the Masterdata to accomodate the PageFooter, instead the PageFooter is printed over the MasterData.
Any help would be appreciated, I have searched in vain for answers on the net.
Below is the code I'm using, attached is a screenshot of the bottom of my report:
I am creating a Fast Report at runtime, entirely from code. The problem is, the data runs off the page (pagesize being A4, didn't set it specifically), or rather it clips the last line printed on page. Report is transported to PDF, but doing Report.ShowReport(...) it also runs off the page. Additionally, if i add a PageFooter to the report, it does not resize the Masterdata to accomodate the PageFooter, instead the PageFooter is printed over the MasterData.
Any help would be appreciated, I have searched in vain for answers on the net.
Below is the code I'm using, attached is a screenshot of the bottom of my report:
var
ReportTable : TfrxDBDataset;
Report : TfrxReport;
DataPage : TfrxDataPage;
Page : TfrxReportPage;
PageHeader : TfrxPageHeader;
PageFooter : TfrxPageFooter;
Band : TfrxBand;
DataBand : TfrxMasterData;
Memo : TfrxMemoView;
frxInterface : TgtFRExportInterface;
gtPDFEngine : TgtPDFEngine;
X,Y, aWidth : Extended;
i : Integer;
List : TList<TfrField>;
fField : TfrField;
begin
try
fTableARTrans.DisableControls;
ReportTable := TfrxDbDataset.Create(Self);
ReportTable.Dataset := fTableArTrans; //A dataset
Report := TfrxReport.Create(Self);
Report.Datasets.Add(ReportTable);
DataPage := TfrxDataPage.Create(Report);
Page := TfrxReportPage.Create(Report);
Page.CreateUniqueName;
Page.SetDefaults;
//Title
PageHeader := TfrxPageHeader.Create(Page);
PageHeader.CreateUniqueName;
PageHeader.SetBounds(0,0,Page.Width - 75.6,50); // poPortrait
with TfrxMemoView.Create(PageHeader) do
begin
CreateUniqueName;
Align := baCenter;
AutoWidth := TRUE;
HAlign := haCenter;
SetBounds(0,4,0,24);
Font.Size := 12;
Font.Style := [fsBold];
Text := 'Accounts receivable - Transactions';
end;
with TfrxMemoView.Create(PageHeader) do
begin
CreateUniqueName;
Align := baCenter;
AutoWidth := TRUE;
HAlign := haCenter;
SetBounds(0,28,0,16);
Text := 'Ne?°ri texti';
end;
//MasterData - The columns
DataBand := TfrxMasterData.Create(Page);
DataBand.CreateUniqueName;
DataBand.Dataset := ReportTable;
DataBand.Top := 50;
DataBand.Height := 20;
X := 0;
Y := 100;
List := CreateFieldList; //A list containing pairs of FieldNames and DisplayNames of the columns
for i := 0 to pred(List.Count) do
begin
aWidth := 100;
If StringMin(fTableARTrans.Obj.Text.FieldName, List[i].FieldName) = 0 then
aWidth := 200;
Memo := TfrxMemoView.Create(DataBand);
Memo.SetBounds(X, Y, aWidth, fr01cm * 5);
Memo.Dataset := ReportTable;
Memo.DataField := List[i].FieldName;
Memo.Style := 'Data';
Memo.Height := DataBand.Height - 1;
with TfrxMemoView.Create(PageHeader) do
begin
CreateUniqueName;
Align := baLeft;
AutoWidth := FALSE;
HAlign := haCenter;
SetBounds(X,50,aWidth,16);
Text := List[i].FieldTitle;
end;
X := X + aWidth;
end;
//footer
PageFooter := TfrxPageFooter.Create(Page);
PageFooter.CreateUniqueName;
PageFooter.SetBounds(0,70,Page.Width - 75.6,20); //ath. poLandscape
with TfrxMemoView.Create(PageFooter) do
begin
CreateUniqueName;
Text := ' [Page#] of [TotalPages#] ',[];
Height := 20;
Align := baClient;
VAlign := vaCenter;
HAlign := haCenter;
Frame.Typ := [ftTop];
Frame.Width := 1.5;
end;
Page.AlignChildren;
frxInterface := TgtFRExportInterface.Create(Self);
gtPDFEngine := TgtPDFEngine.Create(Self);
gtPDFEngine.Preferences.ShowSetupDialog := FALSE;
gtPDFEngine.Preferences.OpenAfterCreate := TRUE;//OpenPDF;
frxInterface.Engine := gtPDFEngine;
frxInterface.RenderDocument(Report, false, false);
finally
if Assigned(List) then
begin
for fField in List do
begin
fField.Free;
end;
SafeFree(List);
end;
fTableARTrans.EnableControls;
end;
end;
Comments
Adding Stretched := TRUE to the bands and adding StretchMode := smActualHeight to the memos I got it to work as intended.