Page 1 of 1

PDF Export Problems

Posted: Mon Apr 18, 2016 2:45 am
by 17576646
I have created a simple FMX program to demonstrate some problems with the PDF export facility in the latest version of TChart Pro. The first figure is a screen capture of my program. The second figure is a screen capture of the resulting PDF. (The graph axis ranges and tick marks have been set manually rather than automatically by TChart.)

My issues with the PDF are listed below:
(1) The font family is not respected but instead a default font is used in the PDF. This is a major problem when using TChart for commercial software development. A fully functional PDF export would respect all the chart properties.
(2) The left axis title is wrongly positioned in the PDF. It clashes with the left axis labels. (If the left axis is created automatically by TChart, rather than manually as here, the clashing is not as bad but still occurs. The clashing is also worse for larger font sizes. Note that the problem is only with the left axis, the bottom axis is fine.)
(3) With a large axis label font, the rightmost label on the bottom axis has been cropped.
(4) Trying to convert the PDF to JPG so I could show it as an Image
Image
Image

Code: Select all

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.Controls.Presentation, FMX.StdCtrls, FMXTee.Engine, FMXTee.Procs,
  FMXTee.Chart, FMXTee.Series, System.UIConsts, FMX.TMSToolBar,
  FMXTee.Canvas.PDF, FMXTee.Canvas;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
var
  c: TPDFCanvas;
  MyRect: TRectF;
begin
  c := TPDFCanvas.Create;
  try
    MyRect := TRectF.Create(0, 0, Chart1.Width, Chart1.Height);
    TPDFExportFormat.Draw(c, Chart1, MyRect);
    with TSaveDialog.Create(nil) do
      try
        Filter := 'Adobe PDF files (*.pdf)|*.pdf';
        DefaultExt := 'pdf';
        if Execute then
          c.SaveToFile(Filename);
      finally
        Free;
      end;
  finally
    c.Free;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
  X, Y: Double;
begin
  with Chart1 do
  begin
    // Set some chart properties
    View3D := False;
    BevelWidth := 0;
    Shadow.Visible := False;
    BottomAxis.Title.Text := 'Bottom axis title';
    LeftAxis.Title.Text := 'Left axis title';
    // SET BOTTOM AXIS RANGE AND TICK MARKS
    Axes.Bottom.SetMinMax(0.5, 2.5);
    for I := 0 to 4 do
      Axes.Bottom.Items.Add(I + 0.5, FloatToStr(I + 0.5));
    // SET LEFT AXIS RANGE AND TICK MARKS
    Axes.Left.SetMinMax(1, 4);
    for I := 0 to 3 do
      Axes.Left.Items.Add(I + 1, IntToStr(I + 1));
    Title.Text[0] := 'Chart Title';
    Title.Font.Color := claBlue;
    Title.Font.Name := 'Courier';
    Title.Font.Style := [TFontStyle.fsBold];
    Title.Font.Size := 36;
    Subtitle.Text[0] := 'Chart Subtitle';
    Subtitle.Font.Color := claRed;
    Subtitle.Font.Name := 'Arial';
    AddSeries(TLineSeries.Create(Self));
    // WITH BIGGER FONTS, CLASHING IS WORSE
    LeftAxis.Title.Font.Size := 24;
    LeftAxis.LabelsFont.Size := 18;
    BottomAxis.Title.Font.Size := 24;
    BottomAxis.LabelsFont.Size := 18;
    Legend.LegendStyle := lsSeries;
    Legend.Alignment := laTop;
    Series[0].LegendTitle := 'Series Legend Title';
    // Create series data
    for I := 0 to 20 do
    begin
      X := 0.5 + I * 0.1;
      Y := 3 / X;
      Series[0].AddXY(X, Y);
    end;
  end;
end;

end.

Re: PDF Export Problems

Posted: Sat Apr 23, 2016 4:45 am
by 17576646
It's been a week and no response! May we expect a fix to the TChart PDF exporter to resolve the listed problems? In the meantime, is there any workaround?

Re: PDF Export Problems

Posted: Mon Apr 25, 2016 11:35 am
by yeray
Hello,

I'm sorry for the delay here.

It seems you are you generating the pdfs in OSX, is that correct?
Have you tried another OS?
riskassessor wrote:(1) The font family is not respected but instead a default font is used in the PDF. This is a major problem when using TChart for commercial software development. A fully functional PDF export would respect all the chart properties.
It sounds as the same here.
http://bugs.teechart.net/show_bug.cgi?id=1477
We have a fix on the roads for it.
riskassessor wrote:(2) The left axis title is wrongly positioned in the PDF. It clashes with the left axis labels. (If the left axis is created automatically by TChart, rather than manually as here, the clashing is not as bad but still occurs. The clashing is also worse for larger font sizes. Note that the problem is only with the left axis, the bottom axis is fine.)
(3) With a large axis label font, the rightmost label on the bottom axis has been cropped.
I could reproduce the problems so I've added them to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1521
riskassessor wrote:(4) Trying to convert the PDF to JPG so I could show it as an [img] here, I received the error message shown in the third figure. It appears that the PDF has an internal structure not fully compatible with Acrobat (Pro DC).
I haven't been able to reproduce that one because we don't have Acrobat Pro here. Do you know another way to reproduce that?
riskassessor wrote:In the meantime, is there any workaround?
A workaround is to generate the pdf using a virtual pdf printer instead of the internal export feature.

Re: PDF Export Problems

Posted: Mon Apr 25, 2016 5:39 pm
by 17576646
In response to your question, the pdf issues are the same whether the Firemonkey program is compiled for OS X or Windows.

A virtual pdf printer is not a workaround for me since I am developing commercial software and cannot require users to have virtual pdf printers.

I hope you can issue a revised pdf export facility in the near future that embeds the fonts and also places the titles and labels so as to faithfully reproduce the chart as displayed on the screen.