type TSPdfBordersRange = class(TSPdfBasicRange) uses TSColorToolKit; public function Create(); function Do();override; public TcPr: TcPr; Left: boolean; Top: boolean; Right: boolean; Bottom: boolean; private function SetDash(val: string); function DrawLine(border: Border; x1: real; y1: real; x2: real; y2: real); end; function TSPdfBordersRange.Create(); begin class(TSPdfBasicRange).Create(); {self.}TcPr := nil; {self.}Left := false; {self.}Top := false; {self.}Right := false; {self.}Bottom := false; end; function TSPdfBordersRange.Do();override; begin // println("Left = {}, Top = {}, Right = {}, Bottom = {}, Tl2Br = {}, Tr2Bl = {}", Left, Top, Right, Bottom, Tl2Br, Tr2Bl); if {self.}TcPr.Shd.Fill and {self.}TcPr.Shd.Fill <> "auto" then begin [r, g, b] := TSColorToolKit.HexToRGB({self.}TcPr.Shd.Fill); {self.}TSPage.PdfPage.SetRGBFill(r/255, g/255, b/255); {self.}TSPage.PdfPage.Rectangle({self.}EndX, {self.}EndY - {self.}DynamicHeight, {self.}Width, {self.}DynamicHeight); {self.}TSPage.PdfPage.Fill(); {self.}TSPage.PdfPage.SetRGBFill(0, 0, 0); {self.}Left := true; end borders := {self.}TcPr.TcBorders; if {self.}Left then {self.}DrawLine(borders.Left, {self.}EndX, {self.}EndY, {self.}EndX, {self.}EndY - {self.}DynamicHeight); if {self.}Top then {self.}DrawLine(borders.Top, {self.}EndX, {self.}EndY, {self.}EndX + {self.}Width, {self.}EndY); if {self.}Right then {self.}DrawLine(borders.Right, {self.}EndX + {self.}Width, {self.}EndY, {self.}EndX + {self.}Width, {self.}EndY - {self.}DynamicHeight); if {self.}Bottom then {self.}DrawLine(borders.Bottom, {self.}EndX, {self.}EndY - {Self.}DynamicHeight, {self.}EndX + {self.}Width, {self.}EndY - {self.}DynamicHeight); if borders.Tl2Br then {self.}DrawLine(borders.Tl2Br, {self.}EndX, {self.}Y, {self.}EndX + {self.}Width, {self.}EndY - {self.}DynamicHeight); if borders.Tr2Bl then {self.}DrawLine(borders.Tr2Bl, {self.}EndX + {self.}Width, {self.}Y, {self.}EndX, {self.}EndY - {self.}DynamicHeight); end; function TSPdfBordersRange.SetDash(val: string); begin if val = "single" or ifnil(val) then {self.}TSPage.PdfPage.SetDash(array(), 0, 0); if val = "dashed" then {self.}TSPage.PdfPage.SetDash(array(1), 1, 0); end; function TSPdfBordersRange.DrawLine(border: Border; x1: real; y1: real; x2: real; y2: real); begin [r, g, b] := array(0, 0, 0); line_width := border.Sz ?: 0.5; {self.}SetDash(border.Val); if border.Color and border.Color <> "auto" then [r, g, b] := TSColorToolKit.HexToRGB(border.Color); {self.}TSPage.PdfPage.SetRGBStroke(r, g, b); {self.}TSPage.PdfPage.SetLineWidth(line_width); {self.}TSPage.PdfPage.MoveTo(x1, y1); {self.}TSPage.PdfPage.LineTo(x2, y2); {self.}TSPage.PdfPage.Stroke(); {self.}TSPage.PdfPage.SetRGBStroke(0, 0, 0); end;