This HotPDF Component Sample draw plots with Delphi TCanvas.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
program CanvasDraw; {$APPTYPE CONSOLE} uses {$IFDEF VER230} System.SysUtils, System.Classes, Vcl.Graphics, {$ELSE} SysUtils, Classes, Graphics, {$ENDIF} HPDFDoc; var I, Y: Integer; HotPDF: THotPDF; begin HotPDF:= THotPDF.Create(nil); try Randomize; HotPDF.AutoLaunch := true; HotPDF.FileName := 'CanvasDraw.pdf'; HotPDF.BeginDoc; // Create PDF file HotPDF.Canvas.Font.Size := 14; // Set canvas font size I :=20; Y := 60; HotPDF.Canvas.TextOut(10, 30, 'Canvas Rectangles'); // Print text while I <= 700 do begin // Draw colour HotPDF.Canvas.Brush.Color := random($FFFFFF); // rectangles HotPDF.Canvas.Rectangle(I, Y, I+90, Y + 160); Inc(I, 30); Inc( Y, 3 ); end; I :=20; Y := 350; HotPDF.Canvas.TextOut(10, 320, 'Canvas Ellipses'); // Print text while I <= 700 do // Draw colour begin // ellipses HotPDF.Canvas.Brush.Color := random($FFFFFF); HotPDF.Canvas.Ellipse(I, Y, I+90, Y + 160); Inc(I, 30); Inc( Y, 3 ); end; I :=20; Y := 680; HotPDF.Canvas.TextOut(10, 650, 'Canvas RoundRects'); // Print text while I <= 700 do begin HotPDF.Canvas.Brush.Color := random($FFFFFF); // Draw colour HotPDF.Canvas.RoundRect(I, Y, I+90, Y + 160, 20, 20); // roundrects Inc(I, 30); Inc( Y, 3 ); end; HotPDF.EndDoc; // Close PDF file finally HotPDF.Free; end; end. |