Browse Source

* Additional fixes for strikethrough/linecap, plus example

git-svn-id: trunk@39468 -
michael 7 years ago
parent
commit
2cf8a9661f
2 changed files with 8 additions and 4 deletions
  1. 4 1
      packages/fcl-pdf/examples/testfppdf.lpr
  2. 4 3
      packages/fcl-pdf/src/fppdf.pp

+ 4 - 1
packages/fcl-pdf/examples/testfppdf.lpr

@@ -170,9 +170,12 @@ begin
   // strike-through text
   P.WriteText(25, 64, 'Strike-Through text', 0, false, true);
 
-  // strike-through text
+  // underline text
   P.WriteText(65, 64, 'Underlined text', 0, true);
 
+  // underline and strikethrough text
+  P.WriteText(120, 64, 'Underlined and strikethrough text', 0, true, true);
+
   // rotated text
   P.SetColor(clBlue, false);
   P.WriteText(25, 100, 'Rotated text at 30 degrees', 30);

+ 4 - 3
packages/fcl-pdf/src/fppdf.pp

@@ -2561,7 +2561,8 @@ constructor TPDFDocumentObject.Create(const ADocument: TPDFDocument);
 begin
   inherited Create(ADocument);
   FDocument:=ADocument;
-  FLineCapStyle := FDocument.LineCapStyle;
+  if Assigned(FDocument) then
+    FLineCapStyle := FDocument.LineCapStyle;
 end;
 
 procedure TPDFDocumentObject.SetWidth(AWidth: TPDFFloat; AStream : TStream);
@@ -3348,8 +3349,8 @@ begin
 
   { line segment is relative to matrix translation coordinate, set above }
   if Underline then
-    WriteString(Format('0 -1.5 m %s -1.5 l S', [FloatStr(mmToPDF(lTextWidthInMM))]) + CRLF, AStream)
-  else
+    WriteString(Format('0 -1.5 m %s -1.5 l S', [FloatStr(mmToPDF(lTextWidthInMM))]) + CRLF, AStream);
+  if StrikeThrough then
     WriteString(Format('0 %s m %s %0:s l S', [FloatStr(mmToPDF(lTextHeightInMM) / 2), FloatStr(mmToPDF(lTextWidthInMM))]) + CRLF, AStream);
 
   { restore graphics state to before the translation matrix adjustment }