fcl-pdf TransformMatrix not set properly for PaperType ptCustom
Original Reporter info from Mantis: alanphys
-
Reporter name: Alan Chamberlain
Original Reporter info from Mantis: alanphys
- Reporter name: Alan Chamberlain
Description:
Setting TPDFDocument.DefaultPaperType to ptCustom with TPDFDocument.Option [poPageOriginAtTop] causes TransformMatrix to be incorrectly initialised.
Steps to reproduce:
Place the following in a procedure and execute
var FDoc:TPDFDocument;
APage:TPDFPage;
CustomPaper:TPDFPaper;
DW,DH:integer;
begin
FDoc := TPDFDocument.Create(Nil);
FDoc.Infos.Title := Application.Title;
FDoc.Infos.Author := 'Me';
FDoc.Infos.Producer := 'fpGUI Toolkit 1.4.1';
FDoc.Infos.ApplicationName := ApplicationName;
FDoc.Infos.CreationDate := Now;
FDoc.Options := [poPageOriginAtTop];
FDoc.FontDirectory := 'fonts';
FDoc.StartDocument;
Section := FDoc.Sections.AddSection;
FDoc.DefaultOrientation := ppoLandscape;
FDoc.DefaultUnitOfMeasure := uomPixels;
FDoc.DefaultPaperType := ptCustom
CustomPaper.H := DH + 2MT;
CustomPaper.W := DW + 2ML;
CustomPaper.Printable.T := 10;
CustomPaper.Printable.L := 10;
CustomPaper.Printable.R := CustomPaper.W - 10;
CustomPaper.Printable.B := CustomPaper.H - 10;
APage := FDoc.Pages.AddPage;
APage.Paper := CustomPaper;
APage.PaperType := FDoc.DefaultPaperType; {does not trigger anything as papertype is the same as previous}
{Print something...}
FDoc.SaveToFile(FileName);
FDoc.Destroy;
end;
Additional information:
TPDFPage.Create initialises the paper and paper size as A4 and then sets the defaults. For ptCustom the paper size is not set and TransformMatrix is set on the A4 size. TPDFPage.SetPaperType and TPDFPage.Orientation both exit without executing AdjustMatrix as these settings are the same as previous.
Work around:
Insert if APage.Orientation = ppoPortrait then {work around to trigger adjustmatrix}
begin
APage.Orientation := ppoLandscape;
APage.Orientation := ppoPortrait;
end
else
begin
APage.Orientation := ppoPortrait;
APage.Orientation := ppoLandscape;
end;
after APage.Paper := CustomPaper;
Possible fix:
In TPDFPage.SetPaperType delete
if FPaperType=AValue then Exit;
so that AdjustMatrix is always executed.
Mantis conversion info:
- Mantis ID: 37265
- OS: Fedora
- OS Build: 32
- Build: 54433
- Platform: i86_64
- Version: 3.2.0
- Fixed in version: 3.3.1
- Fixed in revision: 47394 (#477929d6)
- Target version: 3.2.2