View Issue Details

IDProjectCategoryView StatusLast Update
0037265FPCFCLpublic2020-11-13 07:38
ReporterAlan Chamberlain Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformi86_64OSFedora 
Product Version3.2.0 
Fixed in Version3.3.1 
Summary0037265: fcl-pdf TransformMatrix not set properly for PaperType ptCustom
DescriptionSetting TPDFDocument.DefaultPaperType to ptCustom with TPDFDocument.Option [poPageOriginAtTop] causes TransformMatrix to be incorrectly initialised.
Steps To ReproducePlace 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 + 2*MT;
CustomPaper.W := DW + 2*ML;
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 InformationTPDFPage.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.
TagsNo tags attached.
Fixed in Revision47394
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Marco van de Voort

2020-07-01 10:38

manager   ~0123695

Not being familiar with fcl-pdf I only looked, and adjustmatrix use paperheight, and I'm not sure if it is good practice to manditorily having to set dimensions before setting papertype to ptcustom. Some explicit call for that case might be better?

Michael Van Canneyt

2020-11-12 11:49

administrator   ~0126856

Fixed.
Setting paper type and paper now triggers the matrix calculation.
Manually setting paper will automatically set the paper type to ptCustom.

Thanks for reporting.

Issue History

Date Modified Username Field Change
2020-06-26 10:00 Alan Chamberlain New Issue
2020-07-01 10:38 Marco van de Voort Note Added: 0123695
2020-07-03 21:34 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-07-03 21:34 Michael Van Canneyt Status new => assigned
2020-11-12 11:49 Michael Van Canneyt Status assigned => resolved
2020-11-12 11:49 Michael Van Canneyt Resolution open => fixed
2020-11-12 11:49 Michael Van Canneyt Fixed in Version => 3.3.1
2020-11-12 11:49 Michael Van Canneyt Fixed in Revision => 47394
2020-11-12 11:49 Michael Van Canneyt FPCTarget => 3.2.2
2020-11-12 11:49 Michael Van Canneyt Note Added: 0126856