Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

print a A3 page frontpage/backpage by code

edited March 2003 in RAP
Hi,

I load from file 4 subreports. I arrive to do that with 2 subreports
frontpage but not with 4 subreports frontpage/backpage :

procedure TfrmImpDecla.PrintA3FrontpageBackpage(ppmyReport:TppReport);
var
subRpt:TppSubReport;
subRpt2:TppSubReport;
subRpt3:TppSubReport;
subRpt4:TppSubReport;
subRptA3:TppSubReport;
reportVerso:TppReport;
ppmyregion, ppmyregion2, ppmyregion3, ppmyregion4:TppRegion;
begin
// charges the report with the RTM file
ppmyReport.Template.FileName := ExtractFilePath(ParamStr(0)) +
'reports\blank.rtm';
ppmyReport.Template.LoadFromFile;

// dimension of the main report
ppmyReport.PrinterSetup.Papername := 'A3';
ppmyReport.PrinterSetup.PaperHeight := 297000;
ppmyReport.PrinterSetup.PaperWidth := 420000;
ppmyReport.PrinterSetup.Orientation := poLandscape;

//frontpage/backpage
ppmyReport.PrinterSetup.Duplex := dpHorizontal;

//init the default printer/collation/binname
ppmyReport.PrinterSetup.Printername := 'Default';
ppmyReport.PrinterSetup.Collation := true;
ppmyReport.PrinterSetup.BinName := 'Default';

//init region 1
ppmyRegion := TppRegion.Create(self);
ppmyRegion.Pen.Style := psClear;
ppmyRegion.ParentWidth := false;
ppmyRegion.Band := ppmyreport.HeaderBand;
ppmyRegion.Top := 0;
ppmyRegion.Left := 0;

//init region 2
ppmyRegion2 := TppRegion.Create(self);
ppmyRegion2.Pen.Style := psClear;
ppmyRegion.ParentWidth := false;
ppmyRegion2.Band := ppmyreport.HeaderBand;
ppmyRegion2.Top := 0;
ppmyRegion2.Left := 210000;

//create the report who will appear as subreport of my main
report(ppMyReport)
reportVerso := TppReport.Create(self);
reportVerso.CreateDefaultBands;

//init region 3
ppmyRegion3 := TppRegion.Create(self);
ppmyRegion3.Pen.Style := psClear;
ppmyRegion3.ParentWidth := false;
ppmyRegion3.Band := reportVerso.HeaderBand;
ppmyRegion3.Top := 0;
ppmyRegion3.Left := 0;

//init region 4
ppmyRegion4 := TppRegion.Create(self);
ppmyRegion4.Pen.Style := psClear;
ppmyRegion4.ParentWidth := false;
ppmyRegion4.Band := reportVerso.HeaderBand;
ppmyRegion4.Top := 0;
ppmyRegion4.Left := 210000;

//creates subreport 1
subRpt := TppSubReport.Create(self);
subRpt.CreateReport(ppmyReport);
subRpt.Report.Template.FileName := ExtractFilePath(ParamStr(0)) +
'reports\' + ReportName + '.rtm';
subRpt.Report.Template.LoadFromFile;
subRpt.ParentPrinterSetup := false;
subRpt.Report.PrinterSetup.PaperHeight := 297000;
subRpt.Report.PrinterSetup.PaperWidth := 210000;
subRpt.Report.printersetup.Orientation := poPortrait;
ppmyRegion.Width := subRpt.Report.PrinterSetup.PaperWidth;
ppmyRegion.Height := subRpt.Report.PrinterSetup.PaperHeight;
ppmyRegion.BringToFront;
ppmyRegion.SetBackgroundColor(clWhite,false);
subRpt.Region := ppmyRegion;
subRpt.ParentWidth := false;
subRpt.Width := 210000;

//creates subreport 2
subRpt2 := TppSubReport.Create(self);
subRpt2.CreateReport(ppMyReport);
subRpt2.Report.Template.FileName := ExtractFilePath(ParamStr(0)) +
'reports\' + ReportName2 + '.rtm';
subRpt2.Report.Template.LoadFromFile;
subRpt2.ParentPrinterSetup := false;
subRpt2.Report.PrinterSetup.PaperHeight := 297000;
subRpt2.Report.PrinterSetup.PaperWidth := 210000;
subRpt2.Report.printersetup.Orientation := poPortrait;
ppmyRegion2.Width := subRpt2.Report.PrinterSetup.PaperWidth;
ppmyRegion2.Height := subRpt2.Report.PrinterSetup.PaperHeight;
ppmyRegion2.BringToFront;
ppmyRegion2.SetBackgroundColor(clWhite,false);
subRpt2.Region := ppMyRegion2;
subRpt2.ParentWidth := false;
subRpt2.Width := 210000;

//creates subreport 3
subRpt3 := TppSubReport.Create(self);
subRpt3.CreateReport(reportVerso);
subRpt3.Report.Template.FileName := ExtractFilePath(ParamStr(0)) +
'reports\' + ReportName3 + '.rtm';
subRpt3.Report.Template.LoadFromFile;
subRpt3.ParentPrinterSetup := false;
subRpt3.Report.PrinterSetup.PaperHeight := 297000;
subRpt3.Report.PrinterSetup.PaperWidth := 210000;
subRpt3.Report.printersetup.Orientation := poPortrait;
ppmyRegion3.Width := subRpt3.Report.PrinterSetup.PaperWidth;
ppmyRegion3.Height := subRpt3.Report.PrinterSetup.PaperHeight;
ppmyRegion3.BringToFront;
ppmyRegion3.SetBackgroundColor(clWhite,false);
subRpt3.Region := ppmyRegion3;
subRpt3.ParentWidth := false;
subRpt3.Width := 210000;

//creates subreport 4
subRpt4 := TppSubReport.Create(self);
subRpt4.CreateReport(reportVerso);
subRpt4.Report.Template.FileName := ExtractFilePath(ParamStr(0)) +
'reports\' + ReportName4 + '.rtm';
subRpt4.Report.Template.LoadFromFile;
subRpt4.ParentPrinterSetup := false;
subRpt4.Report.PrinterSetup.PaperHeight := 297000;
subRpt4.Report.PrinterSetup.PaperWidth := 210000;
subRpt4.Report.printersetup.Orientation := poPortrait;
ppmyRegion4.Width := subRpt4.Report.PrinterSetup.PaperWidth;
ppmyRegion4.Height := subRpt4.Report.PrinterSetup.PaperHeight;
ppmyRegion4.BringToFront;
ppmyRegion4.SetBackgroundColor(clWhite,false);
subRpt4.Region := ppMyRegion4;
subRpt4.ParentWidth := false;
subRpt4.Width := 210000;

//creates subreport A3 who contains the reportVerso with the 2 subreports
(3 and 4)
subRptA3 := TppSubReport.Create(self);
subRptA3.CreateReport(ppMyReport);
//Here I'm not sure if it's correct to do that to charge the reportVerso in
the subRptA3 !! Here is perhaps the problem..
subRptA3.Report.template.Report.Create(reportVerso);
subRptA3.PrintBehavior := pbSection;

//and after, we print
ppmyReport.PrinterSetup.DocumentName := frmMain.nom_prenom + ' (' +
ReportTitle + ') - ' + frmMain.Login;
ppmyReport.PrinterSetup.PrinterName := 'Default';
ppmyReport.ShowPrintDialog := false;
ppmyReport.Print;
end;


Thanx a lot

bye

Comments

This discussion has been closed.