It is surprisingly easy to add SVG support to your applications. Here is a third party Delphi and C++ Builder component from WINSOFT that enables work with Scalable Vector Graphics files. Scalable Vector Graphics is XML-based vector image format for two-dimensional graphics.
How to install component
1) Download archive from: https://www.winsoft.sk/svgcanvas.htm
2) Extract files from archive to any folder.
3) You need to copy all files from the folder corresponding to the delphi version to the project folder. Please carefully check your delphi version and folder name because DCUs are version dependent.
4) Compile and execute demo
Example
procedure TFormMain.PaintBoxPaint(Sender: TObject; Canvas: TCanvas);
var
SvgCanvas: TSvgCanvas;
begin
SvgCanvas := TSvgCanvas.Create('filename.svg', Canvas);
try
DrawPicture(SvgCanvas);
finally
SvgCanvas.Free;
end;
end;
procedure TFormMain.DrawPicture(Canvas: TSvgCanvas);
const
LightMask = $707070;
var
Points: array of TPoint;
begin
with Canvas do
begin
Brush.Style := bsSolid;
Pen.Style := psSolid;
Pen.Width := 2;
// draw line
Pen.Color := clYellow;
MoveTo(50, 80);
LineTo(200, 80);
// draw rectangle
Pen.Color := clGreen;
Brush.Color := clGreen or LightMask;
Rectangle(250, 50, 450, 120);
// draw ellipse
Pen.Color := clRed;
Brush.Color := clRed or LightMask;
Ellipse(50, 150, 200, 220);
// draw triangle
Pen.Color := clBlue;
Brush.Color := clBlue or LightMask;
SetLength(Points, 3);
Points[0] := Point(250, 220);
Points[1] := Point(450, 220);
Points[2] := Point(350, 150);
Polygon(Points);
end
end;
After running you will get the resulting file with the following content:
<?xml version=“1.0“ encoding=“UTF-8“ ?> <svg xmlns=“http://www.w3.org/2000/svg“ version=“1.1“> <line x1=“50“ y1=“80“ x2=“200“ y2=“80“ stroke-width=“2“ stroke=“#FFFF00“/> <rect x=“250“ y=“50“ width=“200“ height=“70“ stroke-width=“2“ stroke=“#008000“ fill=“#70F070“/> <ellipse cx=“125“ cy=“185“ rx=“75“ ry=“35“ stroke-width=“2“ stroke=“#FF0000“ fill=“#FF7070“/> <polygon points=“250,220 450,220 350,150“ stroke-width=“2“ stroke=“#0000FF“ fill=“#7070FF“/> </svg>This component was developed by WINSOFT.
The component converts VCL canvas drawing to SVG format
This component has both versions for FireMonkey and for VCL applications to Delphi / C ++ Builder 10 – 10.4.
Works with: Delphi, C ++ Builder, RAD Server
Works on: Windows 32-bit, Windows 64-bit
Source code included in registered version. Royalty free distribution with application without any limitation.
Related links
Here is packages for VCL and Firemonkey:
SVG Canvas library
SVG Canvas library for FireMonkey
Head over and check out the full WINSOFT SVG Canvas library for VCL in Delphi and C++Builder.
Like what you see? You can get SVG Canvas Library and over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4.1 today!
Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Free Delphi Community Edition Free C++Builder Community Edition






How can I realize Delphi Canvas.Draw or StretchDraw in SVGCanvas?
SVGCanvas is part of Winsoft’s third-party control set. The best place to get an answer to this question is to head on over to Winsoft’s website and ask there: https://www.winsoft.sk/svgcanvas.htm