{*********************************************}
{  TeeChart Charting Library for FireMonkey   }
{  Copyright (c) 2012-2020 by Steema Software }
{  All Rights Reserved                        }
{*********************************************}
unit FMXTee.Editor.Export.PDF;
{$I TeeDefs.inc}

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
  System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs,
  {$IFDEF D21}
  FMX.ComboEdit,
  {$ENDIF}
  FMX.StdCtrls, FMXTee.Canvas.PDF, FMXTee.RadioGroup, FMX.ListBox;

type
  TPDFOptions = class(TForm)
    Label1: TLabel;
    CBPageSize: TComboBox;
    RGOrient: TRadioGroup;
    Label2: TLabel;
    CBPosition: TComboBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    procedure FormActivate(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { Private declarations }
    IFormat : TPDFExportFormat;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

procedure TPDFOptions.FormActivate(Sender: TObject);
begin
  if not Assigned(IFormat) then
  begin
    IFormat:=TPDFExportFormat(TagObject);

    if Assigned(IFormat) then
    begin
      CBPageSize.ItemIndex:=Ord(IFormat.PageSize);
      RGOrient.ItemIndex:=Ord(IFormat.Orientation);
      CBPosition.ItemIndex:=Ord(IFormat.Position);
    end;
  end;
end;

procedure TPDFOptions.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  if Assigned(IFormat) then
  begin
    IFormat.PageSize:=TPDFPageSize(CBPageSize.ItemIndex);
    IFormat.Orientation:=TPDFPageOrientation(RGOrient.ItemIndex);
    IFormat.Position:=TPDFPosition(CBPosition.ItemIndex);
  end;

  CanClose:=True;
end;

initialization
  RegisterClass(TPDFOptions);
finalization
  UnRegisterClass(TPDFOptions);
end.
