Page 1 of 1

Export Chart to PDF

Posted: Sat Jan 05, 2019 8:26 pm
by 16484799
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

Re: Export Chart to PDF

Posted: Wed Jan 09, 2019 3:09 pm
by 16484799
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?

Re: Export Chart to PDF

Posted: Fri Jan 11, 2019 4:21 pm
by Marc
Hello,

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

Regards,
Marc Meumann

Re: Export Chart to PDF

Posted: Tue Jan 07, 2020 1:48 pm
by 16485896
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

Re: Export Chart to PDF

Posted: Thu Jan 30, 2020 3:08 pm
by Marc
Hello Flair58,

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

Regards,
Marc