Advertisement
Guest User

Untitled

a guest
Jul 14th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type
  2.   TForm1 = class(TForm)
  3.     Button1: TButton;
  4.     ADODataSet1: TADODataSet;
  5.     DataSource1: TDataSource;
  6.     DBGrid1: TDBGrid;
  7.     procedure FormCreate(Sender: TObject);
  8.     procedure Button1Click(Sender: TObject);
  9.   private
  10.     { Private declarations }
  11.   public
  12.     { Public declarations }
  13.   end;
  14.  
  15. var
  16.   Form1: TForm1;
  17.  
  18. implementation
  19.  
  20. uses
  21.   Printers,
  22.  
  23.   gtUtils3,
  24.   gtCstDocEng,
  25.   gtPDFEng,
  26.   gtCstPDFEng,
  27.   gtExPDFEng;
  28.  
  29. {$R *.dfm}
  30.  
  31. procedure TForm1.FormCreate(Sender: TObject);
  32. begin    
  33.   Self.BiDiMode := bdRightToLeft;
  34.   SysLocale.MiddleEast := True;
  35.   Self.Font.Name := 'Tahoma';
  36.  
  37.   ADODataSet1.LoadFromFile('data.xml');
  38. end;
  39.  
  40. procedure TForm1.Button1Click(Sender: TObject);
  41. var
  42.   FEngine: TgtPDFEngine {TgtCustomDocumentEngine};
  43.  
  44.   LColumns: TList;
  45.   I, NoColumns: Integer;
  46.   ds: TADODataSet;
  47.   S: WideString;  
  48. begin
  49.   FEngine := TgtPDFEngine.Create(Self);
  50.  
  51.   with {IgtDocumentEngine} (FEngine) do
  52.   begin
  53.     FileName := ExtractFilePath(Application.ExeName) + 'AdvancedFeatures';
  54.     // Preferences.ShowSetupDialog := False; // @@@
  55.     FEngine.MeasurementUnit := muPixels;
  56.     FEngine.BiDiMode := bdRightToLeft;
  57.     Page.PaperSize := A4;
  58.     // Page.Orientation := Printers.poLandscape;  // poPortrait, poLandscape
  59.     BeginDoc;
  60.     if (FEngine.EngineStatus <> esStarted) then
  61.       Exit;
  62.  
  63.     TextFormatting.Alignment := haCenter;
  64.     TextFormatting.BeforeSpace := 125;
  65.     Font.Name := 'Arial';
  66.     Font.Color := clBlue;
  67.  
  68.     (*
  69.     Font.Size := 18;
  70.     Font.Style := [fsBold];
  71.     BeginPara;
  72.     TextOut('Advanced Drawing Functions');
  73.     EndPara;
  74.     *)
  75.  
  76.     Font.Size := 7;
  77.     Font.Style := [];
  78.     // TableSettings.AutoAdjustColumnWidth := True; // @@@
  79.  
  80.     with TableSettings do
  81.     begin
  82.       EnableTitle := True;
  83.       ColumnWidth := 100;
  84.       RowHeight := 40;
  85.       TitleHeight := 10;
  86.       InternalMargin := gtRect(5, 5, 5, 5);
  87.     end;
  88.  
  89.     ds := ADODataSet1;
  90.     NoColumns := ds.FieldCount;
  91.     LColumns := BeginTable(40 {X}, 220 {Y}, NoColumns);
  92.  
  93.     for I := 0 to NoColumns - 1 do
  94.     begin
  95.       // TgtColumn(LColumns[I]).Width := DBGrid1.Columns[I].Width;
  96.       TgtColumn(LColumns[I]).Width := 220; // TODO: calculate. if not specified then TableSettings.ColumnWidth is used
  97.       TgtColumn(LColumns[I]).Title := DBGrid1.Columns[I].Title.Caption; // ???
  98.  
  99.       TgtColumn(LColumns[I]).Alignment := haRight;
  100.     end;
  101.  
  102.     ds.First;
  103.     while not ds.Eof do
  104.     begin
  105.       NewRow;
  106.       for I := 0 to ds.FieldCount - 1 do
  107.       begin
  108.         S := ds.Fields[I].AsString;
  109.         TextOut(I, S);
  110.       end;
  111.       ds.Next;
  112.     end;
  113.  
  114.     EndTable;
  115.  
  116.     EndDoc;
  117.   end;
  118.  
  119.   FEngine.Free;
  120. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement