RxFPC: RxDBGrid - fix export to pdf

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5833 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2017-04-12 11:29:56 +00:00
parent e9ca7a1e2d
commit f39df9a19f
8 changed files with 1193 additions and 1036 deletions

View File

@ -409,7 +409,7 @@ var
begin
fX := ConvetUnits(X);
fY := ConvetUnits(Y);
fY := ConvetUnits(Y+2);
fW := ConvetUnits(W);
fH := ConvetUnits(H);
@ -424,26 +424,27 @@ begin
case ATextAlign of
taLeftJustify:
begin
Y1:=fY - FTH2;
// Y1:=fY - FTH2;
X1:=fX + ConvetUnits(constCellPadding);
end;
taRightJustify:
begin
Y1:=fY - FTH2;
// Y1:=fY - FTH2;
X1:=fX + fW - FTW - ConvetUnits(constCellPadding);
if X1 < fX then
X1:=fX;
end;
taCenter:
begin
Y1:=fY - FTH2;
// Y1:=fY - FTH2;
X1:=fX + fW / 2 - FTW / 2 - ConvetUnits(constCellPadding);
if X1 < fX then
X1:=fX;
end;
end;
FCurPage.WriteText(X1, Y1 + fH, AText);
Y1:=fY + FTH2;
FCurPage.WriteText(X1, Y1 {- fH}, AText);
end;
procedure TRxDBGridExportPDF.DrawRect(X, Y, W, H: integer; ABorderColor,
@ -509,7 +510,7 @@ begin
end;
Y1:=Y1 + fW1;
FCurPage.DrawImage(X1, Y1, fW1, fH1, IDX); // left-bottom coordinate of image
FCurPage.DrawImage(X1, Y1, fW1, fH1, IDX);
finally
S.Free;
@ -791,7 +792,7 @@ begin
FPDFDocument.Infos.ApplicationName := ApplicationName;
FPDFDocument.Infos.CreationDate := Now;
FPDFDocument.Options:=FPdfOptions.FOptions;
FPDFDocument.Options:=FPdfOptions.FOptions + [poPageOriginAtTop];
FPDFDocument.DefaultOrientation:=FPdfOptions.PaperOrientation;
//calc need count pages for all columns
@ -853,9 +854,9 @@ begin
FFontItems:=TExportFonts.Create(Self);
FWorkPages:=TFPList.Create;
try
FPDFDocument.StartDocument;
DoSetupFonts;
DoSetupDocHeader;
FPDFDocument.StartDocument;
FCurSection := FPDFDocument.Sections.AddSection; // we always need at least one section
FDataSet.First;
repeat
@ -869,9 +870,6 @@ begin
DoExportFooter;
end;
//DoTest; //!!!!
DoSaveDocument;
Result:=true;
finally
@ -895,6 +893,7 @@ end;
function TRxDBGridExportPDF.DoSetupTools: boolean;
begin
RxDBGridExportPdfSetupForm:=TRxDBGridExportPdfSetupForm.Create(Application);
RxDBGridExportPdfSetupForm.FileNameEdit1.FileName:=FileName;
RxDBGridExportPdfSetupForm.cbOpenAfterExport.Checked:=FOpenAfterExport;
RxDBGridExportPdfSetupForm.cbExportColumnHeader.Checked:=repExportTitle in FOptions;

View File

@ -1,21 +1,21 @@
object RxDBGridExportPdfSetupForm: TRxDBGridExportPdfSetupForm
Left = 544
Height = 345
Top = 387
Height = 416
Top = 316
Width = 522
Caption = 'Export params'
ClientHeight = 345
ClientHeight = 416
ClientWidth = 522
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.7'
LCLVersion = '1.9.0.0'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 6
Height = 20
Height = 13
Top = 6
Width = 105
Width = 78
BorderSpacing.Around = 6
Caption = 'Export file name'
FocusControl = FileNameEdit1
@ -28,8 +28,8 @@ object RxDBGridExportPdfSetupForm: TRxDBGridExportPdfSetupForm
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 12
Height = 37
Top = 32
Height = 21
Top = 25
Width = 504
Filter = 'All files (*.*)|*.*|LibreOffice/OpenOffice (*.ods)|*.ods|Excell 97-2003|*.xls|Excell 2007-2013|*.xlxs'
FilterIndex = 0
@ -44,8 +44,8 @@ object RxDBGridExportPdfSetupForm: TRxDBGridExportPdfSetupForm
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 46
Top = 293
Height = 34
Top = 376
Width = 510
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
@ -58,266 +58,275 @@ object RxDBGridExportPdfSetupForm: TRxDBGridExportPdfSetupForm
TabOrder = 1
ShowButtons = [pbOK, pbCancel, pbHelp]
end
object PageControl1: TPageControl
object GroupBox1: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = FileNameEdit1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel1
Left = 6
Height = 212
Top = 75
Height = 117
Top = 52
Width = 510
ActivePage = TabSheet2
Anchors = [akTop, akLeft, akRight, akBottom]
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
TabIndex = 1
Caption = 'Global'
ClientHeight = 99
ClientWidth = 506
TabOrder = 2
object TabSheet1: TTabSheet
Caption = 'Global'
ClientHeight = 178
ClientWidth = 500
object cbOpenAfterExport: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = TabSheet1
Left = 8
Height = 24
Top = 6
Width = 141
BorderSpacing.Around = 6
Caption = 'Open after export'
TabOrder = 0
end
object cbExportColumnHeader: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = cbOpenAfterExport
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 36
Width = 167
BorderSpacing.Around = 6
Caption = 'Export column header'
TabOrder = 1
end
object cbExportColumnFooter: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = cbExportColumnHeader
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 66
Width = 162
BorderSpacing.Around = 6
Caption = 'Export column footer'
TabOrder = 2
end
object cbExportCellColors: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = cbExportColumnFooter
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 96
Width = 138
BorderSpacing.Around = 6
Caption = 'Export cell colors'
TabOrder = 3
end
object cbOverwriteExisting: TCheckBox
AnchorSideLeft.Control = Label4
AnchorSideTop.Control = TabSheet1
Left = 256
Height = 24
Top = 6
Width = 168
BorderSpacing.Around = 6
Caption = 'Overwrite existing file'
Enabled = False
TabOrder = 4
end
object Label4: TLabel
AnchorSideLeft.Control = TabSheet1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = TabSheet1
Left = 250
Height = 1
Top = 0
Width = 1
ParentColor = False
end
object CheckBox6: TCheckBox
AnchorSideLeft.Control = Label4
AnchorSideTop.Control = cbOverwriteExisting
AnchorSideTop.Side = asrBottom
Left = 256
Height = 24
Top = 36
Width = 117
BorderSpacing.Around = 6
Caption = 'Export images'
TabOrder = 5
end
object Label5: TLabel
AnchorSideLeft.Control = Label4
AnchorSideTop.Control = CheckBox6
AnchorSideTop.Side = asrBottom
Left = 256
Height = 20
Top = 66
Width = 64
BorderSpacing.Around = 6
Caption = 'Title color'
ParentColor = False
end
object ColorBox1: TColorBox
AnchorSideLeft.Control = Label5
AnchorSideTop.Control = Label5
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TabSheet1
AnchorSideRight.Side = asrBottom
Left = 262
Height = 36
Top = 92
Width = 232
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors]
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
ItemHeight = 0
TabOrder = 6
end
object ColorBox1: TColorBox
AnchorSideLeft.Control = Label5
AnchorSideTop.Control = Label5
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox1
AnchorSideRight.Side = asrBottom
Left = 265
Height = 22
Top = 71
Width = 235
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors]
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
ItemHeight = 16
TabOrder = 0
end
object TabSheet2: TTabSheet
Caption = 'PDF Options'
ClientHeight = 178
ClientWidth = 500
object Label2: TLabel
AnchorSideLeft.Control = Label3
AnchorSideTop.Control = TabSheet2
Left = 256
Height = 20
Top = 6
Width = 70
BorderSpacing.Around = 6
Caption = 'Paper type'
ParentColor = False
end
object ComboBox1: TComboBox
AnchorSideLeft.Control = Label2
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TabSheet2
AnchorSideRight.Side = asrBottom
Left = 262
Height = 36
Top = 32
Width = 232
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
ItemHeight = 0
Style = csDropDownList
TabOrder = 0
end
object RadioGroup1: TRadioGroup
AnchorSideLeft.Control = Label4
AnchorSideTop.Control = ComboBox1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TabSheet2
AnchorSideRight.Side = asrBottom
Left = 265
Height = 69
Top = 74
Width = 229
Anchors = [akTop, akLeft, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Orientation'
ChildSizing.LeftRightSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 48
ClientWidth = 227
Items.Strings = (
'Portrait'
'Landscape'
)
TabOrder = 1
end
object Label3: TLabel
AnchorSideLeft.Control = TabSheet2
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = TabSheet2
Left = 250
Height = 1
Top = 0
Width = 1
ParentColor = False
end
object CheckBox1: TCheckBox
AnchorSideLeft.Control = TabSheet2
AnchorSideTop.Control = TabSheet2
Left = 6
Height = 24
Top = 6
Width = 77
BorderSpacing.Around = 6
Caption = 'Out line'
TabOrder = 2
end
object CheckBox2: TCheckBox
AnchorSideLeft.Control = TabSheet2
AnchorSideTop.Control = CheckBox1
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 36
Width = 121
BorderSpacing.Around = 6
Caption = 'Compress text'
TabOrder = 3
end
object CheckBox3: TCheckBox
AnchorSideLeft.Control = TabSheet2
AnchorSideTop.Control = CheckBox2
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 66
Width = 128
BorderSpacing.Around = 6
Caption = 'Compress fonts'
TabOrder = 4
end
object CheckBox4: TCheckBox
AnchorSideLeft.Control = TabSheet2
AnchorSideTop.Control = CheckBox3
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 96
Width = 140
BorderSpacing.Around = 6
Caption = 'Compress images'
TabOrder = 5
end
object CheckBox5: TCheckBox
AnchorSideLeft.Control = TabSheet2
AnchorSideTop.Control = CheckBox4
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 126
Width = 116
BorderSpacing.Around = 6
Caption = 'Use raw JPEG'
TabOrder = 6
end
object Label5: TLabel
AnchorSideLeft.Control = Label3
AnchorSideTop.Control = CheckBox6
AnchorSideTop.Side = asrBottom
Left = 259
Height = 13
Top = 52
Width = 46
BorderSpacing.Around = 6
Caption = 'Title color'
ParentColor = False
end
object CheckBox6: TCheckBox
AnchorSideLeft.Control = Label3
AnchorSideTop.Control = cbOverwriteExisting
AnchorSideTop.Side = asrBottom
Left = 259
Height = 17
Top = 29
Width = 86
BorderSpacing.Around = 6
Caption = 'Export images'
TabOrder = 1
end
object cbOverwriteExisting: TCheckBox
AnchorSideLeft.Control = Label3
AnchorSideTop.Control = GroupBox1
Left = 259
Height = 17
Top = 6
Width = 123
BorderSpacing.Around = 6
Caption = 'Overwrite existing file'
Enabled = False
TabOrder = 2
end
object cbOpenAfterExport: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = GroupBox1
Left = 6
Height = 17
Top = 6
Width = 106
BorderSpacing.Around = 6
Caption = 'Open after export'
TabOrder = 3
end
object cbExportColumnHeader: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = cbOpenAfterExport
AnchorSideTop.Side = asrBottom
Left = 6
Height = 17
Top = 29
Width = 123
BorderSpacing.Around = 6
Caption = 'Export column header'
TabOrder = 4
end
object cbExportColumnFooter: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = cbExportColumnHeader
AnchorSideTop.Side = asrBottom
Left = 6
Height = 17
Top = 52
Width = 119
BorderSpacing.Around = 6
Caption = 'Export column footer'
TabOrder = 5
end
object cbExportCellColors: TCheckBox
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = cbExportColumnFooter
AnchorSideTop.Side = asrBottom
Left = 6
Height = 17
Top = 75
Width = 99
BorderSpacing.Around = 6
Caption = 'Export cell colors'
TabOrder = 6
end
object Label3: TLabel
AnchorSideLeft.Control = GroupBox1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = GroupBox1
Left = 253
Height = 1
Top = 0
Width = 1
ParentColor = False
end
end
object GroupBox2: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = GroupBox1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 139
Top = 175
Width = 510
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'PDF Options'
ClientHeight = 121
ClientWidth = 506
TabOrder = 3
object CheckBox1: TCheckBox
AnchorSideTop.Control = GroupBox2
Left = 6
Height = 17
Top = 6
Width = 55
BorderSpacing.Around = 6
Caption = 'Out line'
TabOrder = 0
end
object CheckBox2: TCheckBox
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = CheckBox1
AnchorSideTop.Side = asrBottom
Left = 6
Height = 17
Top = 29
Width = 88
BorderSpacing.Around = 6
Caption = 'Compress text'
TabOrder = 1
end
object CheckBox3: TCheckBox
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = CheckBox2
AnchorSideTop.Side = asrBottom
Left = 6
Height = 17
Top = 52
Width = 93
BorderSpacing.Around = 6
Caption = 'Compress fonts'
TabOrder = 2
end
object CheckBox4: TCheckBox
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = CheckBox3
AnchorSideTop.Side = asrBottom
Left = 6
Height = 17
Top = 75
Width = 101
BorderSpacing.Around = 6
Caption = 'Compress images'
TabOrder = 3
end
object CheckBox5: TCheckBox
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = CheckBox4
AnchorSideTop.Side = asrBottom
Left = 6
Height = 17
Top = 98
Width = 84
BorderSpacing.Around = 6
Caption = 'Use raw JPEG'
TabOrder = 4
end
object Label2: TLabel
AnchorSideLeft.Control = Label4
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupBox2
Left = 260
Height = 13
Top = 6
Width = 53
BorderSpacing.Around = 6
Caption = 'Paper type'
ParentColor = False
end
object ComboBox1: TComboBox
AnchorSideLeft.Control = Label2
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom
Left = 266
Height = 21
Top = 25
Width = 234
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
ItemHeight = 13
Style = csDropDownList
TabOrder = 5
end
object RadioGroup1: TRadioGroup
AnchorSideLeft.Control = Label4
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ComboBox1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom
Left = 260
Height = 52
Top = 52
Width = 240
Anchors = [akTop, akLeft, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Orientation'
ChildSizing.LeftRightSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 34
ClientWidth = 236
Items.Strings = (
'Portrait'
'Landscape'
)
TabOrder = 6
end
object Label4: TLabel
AnchorSideLeft.Control = GroupBox2
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = GroupBox2
Left = 253
Height = 1
Top = 0
Width = 1
ParentColor = False
end
end
end

View File

@ -60,15 +60,14 @@ type
ColorBox1: TColorBox;
ComboBox1: TComboBox;
FileNameEdit1: TFileNameEdit;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
PageControl1: TPageControl;
RadioGroup1: TRadioGroup;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
@ -97,7 +96,7 @@ const
{$ENDIF}
implementation
{$IF (FPC_FULLVERSION >= 30101)}
uses rxdconst;
uses rxdconst, LCLIntf;
{$R *.lfm}
@ -107,11 +106,9 @@ procedure TRxDBGridExportPdfSetupForm.FormCreate(Sender: TObject);
var
c: TPDFPaperType;
begin
PageControl1.ActivePageIndex:=0;
Caption:=sExportParams;
TabSheet1.Caption:=sGlobal;
TabSheet2.Caption:=sPDFOptions;
GroupBox1.Caption:=sGlobal;
GroupBox2.Caption:=sPDFOptions;
Label1.Caption:=sExportFileName;
cbOpenAfterExport.Caption:=sOpenAfterExport;
cbExportColumnHeader.Caption:=sExportColumnHeader;