LazReport, lrcodereport: version is 1.0, updated icon, cleanup, first page is now programmers responsability, sample update to export to pdf, from Julio Jimenez Borreguero

git-svn-id: trunk@37321 -
This commit is contained in:
jesus 2012-05-18 17:20:40 +00:00
parent 08de566494
commit 0aeeaa5dc2
6 changed files with 55 additions and 33 deletions

View File

@ -1,22 +1,19 @@
LazarusResources.Add('tlrcodereport','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
+#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147
+#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#7'tIME'#7#220#5#17#19
+#2#19'!'#133#247#11#0#0#1#136'IDATH'#199#221'U1k'#194'`'#16'}'#9'N'#197'E'
+#167'"8'#20'3'#137' '#168'T'#2']#'#14'bG'#23#145'RHJ7'#23#193#138#147#160'E'
+#220#11#173'HK'#23'G'#17#28'B'#226#230' '#14'*'#221'E'#128#187'8y'#29'bClM'
+#19'5K'#251#224#131#11#247'%'#239'{'#247#189#187#0''#29#140#241'A'#18'E:'
+#245#131'/'#205'&c'#154#148'D'#145'l'#163#213'"'#242'x'#180#24' ""I'#20'i4'
+#28#238#28#210#181#143'('#153'HX'#158#244'm0'#192#249'z'#13#16'a'#3#128'5'
+#217#183#151'@V'#20#235'ZD'#163#192'd'#2't'#187'`y'#222't'#219#209#10'bD'#184
+'u'#187#177#201#229#240#202'q'#168':'#174#192#128#234'/9'#215#225#190'31'#9
+#145'}'#130#179'xI'#143'W'#163#154'^2YQ'#144#20#4'-VU<D"'#216'0'#12#234#227
+#241'i'#10#140'%'#211'c'#191#31#143#141#6#192#178'@6{'#26#193#142#130'm|'#229
+#245'"'#151'N'#3#0#222#3#1#148#15'!X'#141'j'#214#10#12'('#31'z'#201'f65*'#184
+'\.q3'#155'iM'#199'q'#168'L'#167#206#216'T'#207#133#195'@'#167#3#176',*'#249
+#188#243#10#158#230's<'#23#139' '#0#247#139#5'.'#156'j4='#215#235#161'^'#218
+#218#185#221'v'#176#209#190#144'Ji'#203#2'G'#207'"YU'#145#20#4'M'#17#195#28
+#214#201#182'fQ('#4#185'P'#0#250'} '#24#180#175#224'N'#146'lU('#236#243#225
+':'#147#1#0'tc1|'#152#188#247'cr}'#255'#'#29#131'8'#207'3'#248'7'#248#4#141
+','#188'xX'#199#141#161#0#0#0#0'IEND'#174'B`'#130
+#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0'+'#0'?'#0#255'Mg'#232'J'#0#0#0
+#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#7'tIME'#7#220#5#18#9''''#14
+#169't'#194'}'#0#0#1'4IDATH'#199#173#148'1n'#194'P'#12#134#255'''e'#234'A:'
+#177'3'#176't'#168'"'#184#4#3#136#199#212#11'tc'#225#14#141'T'#206#129'2'#177
+' =2'#176#192#132':'#247#8#172#238#144#18'Ey'#246#139#13'x'#139#229#248#247
+#231'g'#219#249#197#130#160#180#175#162'p0Z'#246#255'co'#224#210'{T!'#208#247
+'f'#3'KA'#217#237'c'#156#231'b'#224#182','#187'?'#170#11#202#164'$}'#230'\'
+#221'-"'#194#210'{'#177#128'F'#224'e'#248#9#0#184#30#214#17#13'''ND*'#162'L'
+#211#146'T'#27'n'#2#131'7'#224#188#171'},A'#219'4'#4#221#202#207';'#158#166
+#17#184#30#214'w'#17#236'/'#5'F'#175'1I$`'#153#162#152' &'#137#4#172'S$'#189
+#129#248#200#28#193#182',1'#206's'#211#27#136#2'R'#18#201#223#222#131#222'S'
+#209']'#20#141#245'%n'#10'!"T!'#168#15#158#229#22#205'g'#179'Z'#0#0#170#16'L'
+#0#234#147#210'E='#158'l'#9'T'#231#154#179#233#199#227#201'V'#178#128'4~'
+#220#188'K'#190'$'#1#23#220'N'#146#242#169'Z'#148#162#208#248#238'"HQ'#181'c'
+#216'c'#199'U'#195'%'#182'P&'#199#244'YS'#228#184#149'?'#158'@'#239#147#213
+'S'#246#224#15'>'#214#171#183'X'#160'R'#160#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -70,7 +70,6 @@ type
FrameColor: TColor;
BorderLines: TfrFrameBorders;
FrameWidth: double;
CodeFormat: string;
end;
{ TlrCodeReport }
@ -81,7 +80,6 @@ type
XRatio, YRatio: double;
PaperSize, PaperWidth, PaperHeight: integer;
PaperOrientation: TPrinterOrientation;
//PaperSize: TPaperSize
FReport, FOwnedReport: TfrReport;
ABitMap: TBitMap;
SavedLineStyle: TlrLineStyle;
@ -123,7 +121,6 @@ type
function GetPageHeightMM: double;
function GetActivePage: integer;
{* Styles *}
procedure ResetLineStyle;
procedure ResetTextRectStyle;
@ -182,6 +179,7 @@ type
{* Drawring BarCode *}
procedure DrawBarCode(X, Y, W, H: double; Code: string; Style: TlrBarCodeStyle);
published
property OnBeginReport: TNotifyEvent read FOnBeginReport write FOnBeginReport;
property Report: TfrReport read GetReport write SetReport;
@ -226,7 +224,7 @@ begin
PageMargin.Top := 0;
ABitMap := TBitMap.Create; // for canvas stuff
// Set default paper
PaperSize := 9; // A4 check LR_Prntr for a list
PaperSize := 9; // A4 check LR_Prntr unit for a list
PaperWidth := 0;
PaperHeight := 0;
PaperOrientation := poPortrait;
@ -260,7 +258,6 @@ end;
procedure TlrCodeReport.RunReport;
begin
NewPage; // Create the first page
if Assigned(OnBeginReport) then
OnBeginReport(Self);
Report.ShowReport;
@ -475,7 +472,6 @@ begin
Result.FrameColor := clBlack;
Result.BorderLines := [];
Result.FrameWidth := 1;
Result.CodeFormat := 'BARCODE';
end;
function TlrCodeReport.PageCount: integer;
@ -555,7 +551,6 @@ procedure TlrCodeReport.DrawText(X, Y, W, H: double; Text: string;
Style: TlrTextRectStyle);
var
AText: TfrMemoview;
ARect: TRect;
begin
AText := TfrMemoView.Create;
AText.CreateUniqueName;
@ -586,8 +581,6 @@ begin
AText.Memo.Add(Text);
AText.CalcGaps;
ARect := AText.DRect;
//AText.Font.Name:= Style.FontName;
Report.Pages[ActivePage].Objects.Add(AText);
// Update Cursor
Cursor.YTop := AText.Top / YRatio; // adjust to ratio used
@ -780,7 +773,6 @@ begin
ABarCode.FrameColor := Style.FrameColor;
ABarCode.Frames := Style.BorderLines;
ABarCode.FrameWidth := Style.FrameWidth;
ABarCode.FormatStr := Style.CodeFormat;
Report.Pages[ActivePage].Objects.Add(ABarCode);
end;

View File

@ -14,6 +14,7 @@
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Version Major="1"/>
<Files Count="2">
<Item1>
<Filename Value="lr_codereport.lrs"/>

View File

@ -1,15 +1,15 @@
object Form1: TForm1
Left = 296
Height = 358
Height = 397
Top = 163
Width = 458
Caption = 'Form1'
ClientHeight = 358
ClientHeight = 397
ClientWidth = 458
LCLVersion = '1.1'
object Image1: TImage
Left = 8
Height = 301
Height = 300
Top = 8
Width = 443
Anchors = [akTop, akLeft, akRight, akBottom]
@ -2901,6 +2901,16 @@ object Form1: TForm1
OnClick = Button1Click
TabOrder = 0
end
object Button2: TButton
Left = 8
Height = 25
Top = 360
Width = 443
Anchors = [akLeft, akRight, akBottom]
Caption = 'Export to PDF'
OnClick = Button2Click
TabOrder = 1
end
object frTNPDFExport1: TfrTNPDFExport
left = 184
top = 152

View File

@ -14,12 +14,14 @@ type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
frBarCodeObject1: TfrBarCodeObject;
frShapeObject1: TfrShapeObject;
frTNPDFExport1: TfrTNPDFExport;
Image1: TImage;
Report: TlrCodeReport;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ReportBeginReport(Sender: TObject);
private
{ private declarations }
@ -38,7 +40,23 @@ implementation
procedure TForm1.Button1Click(Sender: TObject);
begin
report.RunReport;
//report.RunReport;
if Report.PageCount = 0 then
begin
ReportBeginReport(report);
end;
Report.Report.ShowReport;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//direct export to PDF. Set the desired destination file.
if Report.PageCount = 0 then
begin
ReportBeginReport(report);
Report.Report.PrepareReport;
end;
Report.Report.ExportTo(TfrTNPDFExportFilter, '/tmp/generated-pdf.pdf');
end;
procedure TForm1.ReportBeginReport(Sender: TObject);
@ -51,6 +69,10 @@ begin
begin
// Set paper... 1=Letter 9=A4....
//SetPaper(1, poLandscape); // try uncomment this line to test another paper size
// Important. Before drawing, add a page
NewPage;
// Set up a custom style
BoxText := GetDefaultTextRectStyle;
BoxText.FontName := 'Times';

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

After

Width:  |  Height:  |  Size: 436 B