Export Chart to PDF

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
flair58
Newbie
Newbie
Posts: 2
Joined: Tue Oct 30, 2018 12:00 am

Export Chart to PDF

Post by flair58 » Sat Jan 05, 2019 8:26 pm

Hi,
to export a chart to PDF I'm using

Code: Select all

TeeSaveToPDFFile(Chart1,'Chart1.pdf');
Unfortunately the colors in the pdf file look completely other than on the original chart.
(See attached picture).
printing the chart on a PDF printer works well.
Can anybody explain what to do to get the right colors using TeeSaveToPDFFile?

I' m working with TeeChartVCLFMX-2018.26 and Delphi 10.3 Rio.

Flair58
Attachments
Chart1.jpg
Chart1.jpg (412.78 KiB) Viewed 17063 times

flair58
Newbie
Newbie
Posts: 2
Joined: Tue Oct 30, 2018 12:00 am

Re: Export Chart to PDF

Post by flair58 » Wed Jan 09, 2019 3:09 pm

Hi,
I found the reason of this misbehaviour:
The transparency of the color bands have been set to 80% by program code, but this setting is ignored by the export function TeeSaveToPDFFile.

Here is an example code to comprehend this effect:

Code: Select all

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VclTee.TeeGDIPlus, VCLTee.TeEngine,
  Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.TeeTools, VCLTee.Series,
  Vcl.StdCtrls, VCLTee.TeePDFCanvas;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Button1: TButton;
    Button2: TButton;
    SaveDialog1: TSaveDialog;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  FName: string;
begin
  SaveDialog1.Filter := 'PDF file (*.pdf)|*.pdf';
  if not SaveDialog1.Execute then Exit;
  FName := SaveDialog1.FileName;
  if ExtractFileExt(FName) = '' then FName := FName + '.pdf';
  try
    TeeSaveToPDFFile(Chart1,FName);
  except
    on E:exception do ShowMessage(E.Message);
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  I,Bands: integer;
  W,X: double;
begin
  Chart1.Tools.Clear;
  Bands := 3 + Random(20);
  with Chart1.BottomAxis do W := Maximum - Minimum;
  for I := 0 to Bands-1 do
    begin
      with Chart1.Tools.Add(TColorBandTool) as TColorBandTool do
      begin
        Axis := Chart1.BottomAxis;
        StartValue := Axis.Minimum + I*W/Bands;
        EndValue := StartValue + W/Bands;
        DrawBehindAxes := true;
        AllowDrag := false;
        if Odd(I) then Color := clLime else Color := clYellow;
        ResizeStart := false;
        ResizeEnd := false;
        Pen.Visible := false;
        StartLinePen.Visible := false;
        EndLinePen.Visible := false;
        Transparency := 80;
      end;
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  aLineSeries: TLineSeries;
begin
  aLineSeries := TLineSeries.Create(self);
  Chart1.AddSeries(aLineSeries);
  aLineSeries.FillSampleValues(100);
end;

end.
The results are shown in the attached pictures.

Is there a solution to solve the problem?
Attachments
Chart1.png
Chart1.png (84.58 KiB) Viewed 17034 times

Marc
Site Admin
Site Admin
Posts: 1209
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Export Chart to PDF

Post by Marc » Fri Jan 11, 2019 4:21 pm

Hello,

We can reproduce the problem. Tha transparency is not interpreted for the pdf export. We'll check for a solution.

Regards,
Marc Meumann
Steema Support

flair58
Newbie
Newbie
Posts: 1
Joined: Mon Mar 18, 2019 12:00 am

Re: Export Chart to PDF

Post by flair58 » Tue Jan 07, 2020 1:48 pm

Hello,
almost a year has passed since I published the problem.
But even in the latest TChartVCL Version 2019.28 the problem remains.
Is there any plan to solve the problem?

Kind regards
Flair58

Marc
Site Admin
Site Admin
Posts: 1209
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Export Chart to PDF

Post by Marc » Thu Jan 30, 2020 3:08 pm

Hello Flair58,

We have looked at several options and alternatives but haven't yet found the solution.

Regards,
Marc
Steema Support

Post Reply