Blog

All Blog Posts  |  Next Post  |  Previous Post

Double vector graphics, double quality

Tuesday, November 24, 2020

Intro

TMS VCL UI Pack offers a wide range of visual and non-visual components. Recognizing visual components is easy: drop them on the form and you're ready to go. Non-visual components, which in many cases, carry and support a lot of the visual components are not that recognizable when going on an exploration mission through the contents of the TMS VCL UI Pack. In today's blog post, I want to focus on a non-visual component, and a powerful engine that brings high quality vector graphics to life in your application: TAdvPDFLib & SVG support. When combining both, we get an out of the box, best quality vector graphics experience that will take your application to the next level.

SVG support

A while ago, we added SVG support in TMS VCL UI Pack. Whenever an SVG file is loaded, the internal vector graphics engine takes over and renders the SVG. This all happpens automatically at designtime, but at runtime, when loading an svg, we need to make sure the SVG engine is registered. To do this, add AdvTypes to the uses list. After this unit is added, we can load SVG files by using one of the methods to assign a value to a TPicture property, or any other property included in the TMS VCL UI Pack that support SVG.
uses
  AdvTypes;

procedure TForm1.LoadSVG;
begin
  Image1.Picture.LoadFromFile('nature.svg');
end;


Exporting to PDF

When integrating reporting in your application, you often re-organize your data into a grid / table structure and add a graphic in the form of an image. This could be anything such as a company logo or a chart that accompanies the data. To make sure the image quality is good, the size needs to be large enough. Depending on the way the report is actually displayed or printed, this could result in quality loss as the image is added with a fixed size. By using an SVG, the size does not matter, as it will be rendered by the native PDF graphics engine with the best quality. When we apply this when exporting to PDF, the code looks like this:
uses
  AdvPDFLib, Types;

 procedure TForm1.Button1Click(Sender: TObject);
var
  p: TAdvPDFLib;
begin
  p := TAdvPDFLib.Create;
  try
    p.BeginDocument('SVGToPDF.pdf');
    p.NewPage;
    p.Graphics.DrawImageFromFile('nature.svg', RectF(50, 50, p.PageWidth - 50, 500));
    p.EndDocument(True);
  finally
    p.Free;
  end;
end;


When zooming in, you'll notice that the quality is not affected because of the native vector graphics used inside the PDF document.



Explore!

Go ahead and download TMS VCL UI Pack and explore the vast amount of visual and non-visual features and components.

Pieter Scheldeman




This blog post has received 2 comments.


1. Thursday, March 11, 2021 at 5:44:17 PM

The combination of PDF and SVG is a synergy boost!

Aschbacher Peter


2. Thursday, March 11, 2021 at 6:08:29 PM

Thanks Peter!

Pieter Scheldeman




Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post