procedure TFastReportForm.PrintTitlePage(
var Report: TfrxReport;
TitleText:
string);
var
Page: TfrxReportPage;
Band: TfrxBand;
Memo: TfrxMemoView;
Memo1: TfrxMemoView;
begin
Page := TfrxReportPage.Create(Report);
Page.CreateUniqueName;
Page.SetDefaults;
Band := TfrxReportTitle.Create(Page);
Band.CreateUniqueName;
Band.Top := 0;
Band.Height := Page.Height - 1;
Memo := TfrxMemoView.Create(Band);
Memo.CreateUniqueName;
Memo.Font.Height := 36;
Memo.Text := TitleText;
Memo.SetBounds(x_left, 50, 400, 60);
Memo.Align := baWidth;
Memo1 := TfrxMemoView.Create(Band);
Memo1.CreateUniqueName;
Memo1.Font.Height := 36;
Memo1.Text := '
date :' + DatetoStr(now);
Memo1.SetBounds(x_left, 50, 400, 60);
Memo1.Align := baWidth;
end;
procedure TFastReportForm.PlaceMemoOnPage(
var Memo, MemoS: TfrxMemoView;
DataBand: TfrxMasterData; frxDBDataSet: TfrxDBDataset; row: Integer;
datafieldname:
String);
begin
Memo := TfrxMemoView.Create(DataBand);
Memo.CreateUniqueName;
{ connect to data }
Memo.DataSet := frxDBDataSet;
Memo.DataField := datafieldname;
Memo.SetBounds(x_left, row, 600, 20);
MemoS := TfrxMemoView.Create(DataBand);
MemoS.CreateUniqueName;
MemoS.Text := datafieldname;
MemoS.SetBounds(0, row, 50, 20);
end;
procedure TFastReportForm.ExecuteFastReportV2(Sender: TObject);
var
Report: TfrxReport;
Page: TfrxReportPage;
DataPage: TfrxDataPage;
Band: TfrxBand;
DataBand: TfrxMasterData;
Memo: TfrxMemoView;
Memo_1: TfrxMemoView;
Memo_1S: TfrxMemoView;
Memo_2: TfrxMemoView;
Memo_2S: TfrxMemoView;
Memo_3: TfrxMemoView;
Memo_3S: TfrxMemoView;
Memo_4: TfrxMemoView;
Memo_4S: TfrxMemoView;
Memo_5: TfrxMemoView;
Memo_5S: TfrxMemoView;
Memo_6: TfrxMemoView;
Memo_6S: TfrxMemoView;
Memo_7: TfrxMemoView;
Memo_7S: TfrxMemoView;
Memo_8: TfrxMemoView;
Memo_8S: TfrxMemoView;
Memo_9: TfrxMemoView;
Memo_9S: TfrxMemoView;
Memo_10: TfrxMemoView;
Memo_10S: TfrxMemoView;
DataSet: TfrxDataset;
Frxdataset: TfrxDataset;
ItemIndex: Integer;
ItemCount: Integer;
FooterBand: TfrxBand;
begin
///
/// GUI info :-)
///
StatusBar.SimpleText := '
Prepare Cutframes report .... ';
Application.ProcessMessages;
Report := TfrxReport.Create(
nil);
try
{ add a dataset to the list of ones accessible for a report }
Report.DataSets.Add(frxDBDataset1);
DataPage := TfrxDataPage.Create(Report);
{ add a page }
Page := TfrxReportPage.Create(Report);
{ create a unique name }
Page.CreateUniqueName;
{ set sizes of fields, paper and orientation by default }
Page.SetDefaults;
{ add a page for the first title page }
PrintTitlePage(Report, '
Fast report --- test report (Version 01.2023) !');
{ add a 2nd. title pagefor testing }
PrintTitlePage(Report, '
My new title page');
///
/// report
///
{ add the masterdata band }
DataBand := TfrxMasterData.Create(Page);
DataBand.CreateUniqueName;
DataBand.DataSet := frxDBDataset1;
// DataBand.OnBeforePrint;
{ the Top coordinate should be greater than the previously added band’s top + height }
DataBand.Top := 100;
DataBand.Height := 600;
PlaceMemoOnPage(Memo_1, Memo_1S, DataBand, frxDBDataset1,
y_left_delta, '
Index');
PlaceMemoOnPage(Memo_3, Memo_3S, DataBand, frxDBDataset1,
y_left_delta * 2, '
Name');
.....
PlaceMemoOnPage(Memo_10, Memo_10S, DataBand, frxDBDataset1,
y_left_delta * 10, '
newBMP');
Memo_10.Font.Height := 8;
Memo_10.Font.Color := clblue;
PictureView := TfrxPictureView.Create(DataBand);
PictureView.DataSet := frxDBDataset1;
PictureView.DataField := '
Image';
PictureView.SetBounds(x_left + 10, 450, 300, 300);
Imagefilename := frxDBDataset1.DataSet.FieldByName('
newBMP').AsString;
FooterBand := TfrxFooter.Create(Page);
FooterBand.CreateUniqueName;
FooterBand.Height := 20;
FooterBand.Top := Page.Height - FooterBand.Height;
Memo := TfrxMemoView.Create(FooterBand);
Memo.CreateUniqueName;
Memo.Text := '
This is the footer! (V01)';
Memo.SetBounds(0, Page.Height - 50, Page.Width, FooterBand.Height);
Memo.HAlign := haCenter;
if FOpenReportFlag
then
begin
{ show the report }
Report.ShowReport;
end;
Report.FileName := FReportfilenamePDF;
Save_asPDF_Report(Report);
finally
Report.Free;
end;
///
/// GUI
///
StatusBar.SimpleText := '
[DONE] Build report';
end;
procedure TFastReportForm.Save_asPDF_Report(MyReport: TfrxReport);
begin
MyReport.PrepareReport();
{ Set the range of pages to export. By default, all pages of the generated report are exported. }
// frxPDFExport1.PageNumbers := '2-3';
{ Set the PDF standard
TPDFStandard = (psNone, psPDFA_1a, psPDFA_1b, psPDFA_2a, psPDFA_2b, psPDFA_3a, psPDFA_3b);
It is required to add the frxExportPDFHelpers module to the uses list:
uses frxExportPDFHelpers; }
frxPDFExport1.PDFStandard := psNone;
{ You can set the PDF standard version for PDFStandard = psNone
TPDFVersion = (pv14, pv15, pv16, pv17);
It is required to add the frxExportPDFHelpers module to the uses list:
uses frxExportPDFHelpers; }
frxPDFExport1.PDFVersion := pv17;
{ To get smaller file size, you can set the compression }
frxPDFExport1.Compressed := true;
{ Set whether to embed fonts in the resulting document.
Embedding fonts significantly increases the size of the resulting document }
frxPDFExport1.EmbeddedFonts := False;
{ Set whether we need to export the background image }
frxPDFExport1.Background := true;
{ Disable export of objects with optimization for printing. With option enabled images will be high-quality but 9 times larger in volume }
frxPDFExport1.PrintOptimized := False;
{ Set whether the resulting PDF will contain an external table of contents, as in the original report }
frxPDFExport1.Outline := False;
{ Set whether to export images with transparency }
frxPDFExport1.Transparency := true;
{ You can set the desired DPI of images. Enabling this option disables SaveOriginalImages option, which allows you to save images in their
original form }
frxPDFExport1.PictureDPI := 150;
{ Set the compression ratio of bitmap images }
frxPDFExport1.Quality := 95;
{ Set whether to open the resulting file after export }
frxPDFExport1.OpenAfterExport := False;
{ Set whether to display export progress
(show which page is currently being exported) }
frxPDFExport1.ShowProgress := False;
{ Set whether to display a dialog box with export filter settings }
frxPDFExport1.ShowDialog := False;
{ Set the name of the resulting file. Please note that if you do not set the file name and disable the export filter dialog box, the file name selection dialog will still be displayed }
frxPDFExport1.FileName := FReportfilenamePDF;
{ Fill in the corresponding fields of the Information tab }
frxPDFExport1.Title := '
Your Title';
frxPDFExport1.Author := '
Your Name';
frxPDFExport1.Subject := '
Your Subject';
frxPDFExport1.Keywords := '
Your Keywords';
frxPDFExport1.Creator := '
Creator Name';
frxPDFExport1.Producer := '
Producer Name';
{ Fill in the corresponding fields of the Security tab }
// frxPDFExport1.UserPassword := '1234';
// frxPDFExport1.OwnerPassword := '1234';
frxPDFExport1.ProtectionFlags := [ePrint, eModify, eCopy, eAnnot];
{ Set the Viewer settings (Viewer tab) }
frxPDFExport1.HideToolbar := False;
frxPDFExport1.HideMenubar := False;
frxPDFExport1.HideWindowUI := False;
frxPDFExport1.FitWindow := False;
frxPDFExport1.CenterWindow := False;
frxPDFExport1.PrintScaling := False;
{ Export the report }
MyReport.
Export(frxPDFExport1);
end