* Fix bug ID #0037265, setting paper property needs to calc tranformationmatrix

git-svn-id: trunk@47394 -
This commit is contained in:
michael 2020-11-12 10:48:03 +00:00
parent a8db09b37e
commit 477929d6fe

View File

@ -696,6 +696,7 @@ type
function GetObjectCount: Integer;
function CreateAnnotList: TPDFAnnotList; virtual;
procedure SetOrientation(AValue: TPDFPaperOrientation);
procedure SetPaper(AValue: TPDFPaper);
procedure SetPaperType(AValue: TPDFPaperType);
procedure AddTextToLookupLists(AText: UTF8String);
procedure SetUnitOfMeasure(AValue: TPDFUnitOfMeasure);
@ -785,8 +786,8 @@ type
// Quick settings for Paper.
Property PaperType : TPDFPaperType Read FPaperType Write SetPaperType default ptA4;
Property Orientation : TPDFPaperOrientation Read FOrientation Write SetOrientation;
// Set this if you want custom paper size. You must set this before setting PaperType = ptCustom.
Property Paper : TPDFPaper Read FPaper Write FPaper;
// Set this if you want custom paper size. Setting this will set PaperType to ptCustom.
Property Paper : TPDFPaper Read FPaper Write SetPaper;
// Unit of Measure - how the PDF Page should convert the coordinates and dimensions
property UnitOfMeasure: TPDFUnitOfMeasure read FUnitOfMeasure write SetUnitOfMeasure default uomMillimeters;
Property ObjectCount: Integer Read GetObjectCount;
@ -1241,6 +1242,11 @@ function PDFtoInches(APixels: TPDFFloat): single;
function PDFCoord(x, y: TPDFFloat): TPDFCoord;
Operator = (a,b : TPDFDimensions) z : boolean;
Operator = (a,b : TPDFPaper) z : boolean;
implementation
uses
@ -1285,6 +1291,19 @@ const
Var
PDFFormatSettings : TFormatSettings;
Operator = (a,b : TPDFDimensions) z : boolean;
begin
z:=(a.B=b.b) and (a.T=b.t) and (a.l=b.l) and (a.r=b.r);
end;
Operator = (a,b : TPDFPaper) z : boolean;
begin
z:=(a.H=b.H) and (a.W=b.W) and (a.Printable=b.Printable);
end;
function GetLocalTZD(ADate: TDateTime; ISO8601: Boolean): string;
var
i: Integer;
@ -2202,6 +2221,15 @@ begin
AdjustMatrix;
end;
procedure TPDFPage.SetPaper(AValue: TPDFPaper);
begin
if FPaper=AValue then exit;
FPaper:=AValue;
FPaperType:=ptCustom;
// No need to call calcpapersize
AdjustMatrix;
end;
procedure TPDFPage.CalcPaperSize;
var
PP: TPDFPaper;
@ -2229,7 +2257,8 @@ procedure TPDFPage.SetPaperType(AValue: TPDFPaperType);
begin
if FPaperType=AValue then Exit;
FPaperType:=AValue;
CalcPaperSize;
if FPaperType<>ptCustom then
CalcPaperSize;
AdjustMatrix;
end;
@ -2310,20 +2339,21 @@ begin
inherited Create(ADocument);
FLastFont := nil;
FLastFontColor := clBlack;
FPaperType := ptA4;
FUnitOfMeasure := uomMillimeters;
CalcPaperSize;
If Assigned(ADocument) then
begin
begin
PaperType := ADocument.DefaultPaperType;
Orientation := ADocument.DefaultOrientation;
FUnitOfMeasure:=ADocument.DefaultUnitOfMeasure;
end;
end
else
begin
FPaperType:=ptA4;
CalcPaperSize;
FUnitOfMeasure := uomMillimeters;
end;
FMatrix._00 := 1;
FMatrix._20 := 0;
AdjustMatrix;
FAnnots := CreateAnnotList;
end;