View Issue Details

IDProjectCategoryView StatusLast Update
0032448FPCPatchpublic2017-09-20 19:53
ReporterPascal RiekenbergAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSWindows 10 x64OS Version1703
Product Version3.1.1Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0032448: fcl-report: errors in pdf exporter
DescriptionRenderShape is calculation wrong origin.
RenderShapeCircle and RenderShapeRect are calculation wrong offset and origin.
See attached patch and demo PDFs.
TagsNo tags attached.
Fixed in Revision37271
FPCOldBugId
FPCTarget
Attached Files
  • fpreportpdfexport.pp.patch (1,901 bytes)
    Index: packages/fcl-report/src/fpreportpdfexport.pp
    ===================================================================
    --- packages/fcl-report/src/fpreportpdfexport.pp	(revision 37254)
    +++ packages/fcl-report/src/fpreportpdfexport.pp	(working copy)
    @@ -277,12 +277,16 @@
       APage.SetColor(clblack, True);
       APage.SetColor(clblack, False);
     
    +  { PDF origin coordinate is Bottom-Left, and Report Layout is Top-Left }
       lPt1.X := ABand.RTLayout.Left + AShape.RTLayout.Left;
    -  lPt1.Y := ABand.RTLayout.Top + AShape.RTLayout.Top;
    +  lPt1.Y := ABand.RTLayout.Top + AShape.RTLayout.Top + AShape.RTLayout.Height;
     
    -  { Frame must be drawn before the text as it could have a fill color. }
    +  { Frame must be drawn before the shape as it could have a fill color. }
       RenderFrame(APage, ABand, AShape.Frame, lPt1, AShape.RTLayout.Width, AShape.RTLayout.Height);
    -  RenderShape(APage, lPt1, AShape);
    +  { Only render shape when color is set and color is different to frame background color. }
    +  if (TFPReportShape(AShape).Color <> clNone) and
    +  (TFPReportShape(AShape).Color <> AShape.Frame.BackgroundColor) then
    +    RenderShape(APage, lPt1, AShape);
     end;
     
     type
    @@ -442,11 +446,11 @@
       begin
         ldx := 0;
         ldy := (ALayout.Height - ALayout.Width) / 2;
    -    lw := ALayout.Height;
    +    lw := ALayout.Width;
       end;
       { PDF origin coordinate is Bottom-Left, and Report Layout is Top-Left }
       lPt2.X := lPt1.X + ldx;
    -  lPt2.Y := lPt1.Y + ldy;
    +  lPt2.Y := lPt1.Y - ldy;
       APage.DrawEllipse(lPt2, lw, lw, 1, False, True);
     end;
     
    @@ -514,11 +518,11 @@
       begin
         ldx := 0;
         ldy := (ALayout.Height - ALayout.Width) / 2;
    -    lw := ALayout.Height;
    +    lw := ALayout.Width;
       end;
       P.X := lPt1.X + ldx;
       { PDF origin coordinate is Bottom-Left, and Report Layout is Top-Left }
    -  P.Y := lPt1.Y + ldy;
    +  P.Y := lPt1.Y - ldy;
       APage.DrawRect(P, lw, lw, 1, False, True);
     end;
     
    
  • old.pdf (1,966,393 bytes)
  • new.pdf (991,354 bytes)

Activities

Pascal Riekenberg

2017-09-20 12:55

reporter  

fpreportpdfexport.pp.patch (1,901 bytes)
Index: packages/fcl-report/src/fpreportpdfexport.pp
===================================================================
--- packages/fcl-report/src/fpreportpdfexport.pp	(revision 37254)
+++ packages/fcl-report/src/fpreportpdfexport.pp	(working copy)
@@ -277,12 +277,16 @@
   APage.SetColor(clblack, True);
   APage.SetColor(clblack, False);
 
+  { PDF origin coordinate is Bottom-Left, and Report Layout is Top-Left }
   lPt1.X := ABand.RTLayout.Left + AShape.RTLayout.Left;
-  lPt1.Y := ABand.RTLayout.Top + AShape.RTLayout.Top;
+  lPt1.Y := ABand.RTLayout.Top + AShape.RTLayout.Top + AShape.RTLayout.Height;
 
-  { Frame must be drawn before the text as it could have a fill color. }
+  { Frame must be drawn before the shape as it could have a fill color. }
   RenderFrame(APage, ABand, AShape.Frame, lPt1, AShape.RTLayout.Width, AShape.RTLayout.Height);
-  RenderShape(APage, lPt1, AShape);
+  { Only render shape when color is set and color is different to frame background color. }
+  if (TFPReportShape(AShape).Color <> clNone) and
+  (TFPReportShape(AShape).Color <> AShape.Frame.BackgroundColor) then
+    RenderShape(APage, lPt1, AShape);
 end;
 
 type
@@ -442,11 +446,11 @@
   begin
     ldx := 0;
     ldy := (ALayout.Height - ALayout.Width) / 2;
-    lw := ALayout.Height;
+    lw := ALayout.Width;
   end;
   { PDF origin coordinate is Bottom-Left, and Report Layout is Top-Left }
   lPt2.X := lPt1.X + ldx;
-  lPt2.Y := lPt1.Y + ldy;
+  lPt2.Y := lPt1.Y - ldy;
   APage.DrawEllipse(lPt2, lw, lw, 1, False, True);
 end;
 
@@ -514,11 +518,11 @@
   begin
     ldx := 0;
     ldy := (ALayout.Height - ALayout.Width) / 2;
-    lw := ALayout.Height;
+    lw := ALayout.Width;
   end;
   P.X := lPt1.X + ldx;
   { PDF origin coordinate is Bottom-Left, and Report Layout is Top-Left }
-  P.Y := lPt1.Y + ldy;
+  P.Y := lPt1.Y - ldy;
   APage.DrawRect(P, lw, lw, 1, False, True);
 end;
 

Pascal Riekenberg

2017-09-20 12:55

reporter  

old.pdf (1,966,393 bytes)

Pascal Riekenberg

2017-09-20 12:56

reporter  

new.pdf (991,354 bytes)

Michael Van Canneyt

2017-09-20 17:09

administrator   ~0102950

Applied, many thanks for this.
Very strange we didn't notice this in the demos :(

Issue History

Date Modified Username Field Change
2017-09-20 12:55 Pascal Riekenberg New Issue
2017-09-20 12:55 Pascal Riekenberg File Added: fpreportpdfexport.pp.patch
2017-09-20 12:55 Pascal Riekenberg File Added: old.pdf
2017-09-20 12:56 Pascal Riekenberg File Added: new.pdf
2017-09-20 17:09 Michael Van Canneyt Fixed in Revision => 37271
2017-09-20 17:09 Michael Van Canneyt Note Added: 0102950
2017-09-20 17:09 Michael Van Canneyt Status new => resolved
2017-09-20 17:09 Michael Van Canneyt Fixed in Version => 3.1.1
2017-09-20 17:09 Michael Van Canneyt Resolution open => fixed
2017-09-20 17:09 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-09-20 17:09 Michael Van Canneyt Target Version => 3.2.0
2017-09-20 19:53 Pascal Riekenberg Status resolved => closed