#1 2011-04-16 21:20:23

photofritz
Member
Registered: 2011-04-16
Posts: 14

Newbie

Howdy
I would love to use the syn PDF units. I don't see a simple example of what to include in the uses units etc. to write a simple "hello world" program. Maybe I missed that. Is there a step by step? I downloaded the source code, created a new project, but must add units to the Unit1 of my project. Any suggestions? I know delphi well and am using version 2010, and possibly XE in the near future.
Thank you all in advance
Fritz

Offline

#2 2011-04-17 05:38:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: Newbie

For direct use, create the content via the TCanvas available in TPdfDocumentGDI, in unit SynPdf.
See e.g. http://synopse.info/forum/viewtopic.php?id=272

For more high-level use, use the simple report engine , from unit SQLite3Pages.
See e.g. http://synopse.info/forum/viewtopic.php?id=41 and the sample "05 - Report created from code" from our framework.

For direct low-level access, see http://synopse.info/forum/viewtopic.php?id=216
But I think it will no be easy. For low-level, there is all necessary info in the unit comments.

Offline

#3 2011-04-17 20:16:37

photofritz
Member
Registered: 2011-04-16
Posts: 14

Re: Newbie

I Made myself a tiny program if this helps anyone!

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, SynPDF;

type
  TForm1 = class(TForm)
    SpeedButton1: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
lPdf   : TPdfDocumentGDI;
lPage  : TPdfPage;
begin
  lPdf := TPdfDocumentGDI.Create;
  try
    lPdf.Info.Author        := 'Tester';
    lPdf.Info.CreationDate  := Now;
    lPdf.Info.Creator       := 'Tester';
    lPdf.DefaultPaperSize   := psA4;
    lPage := lPDF.AddPage;
    lPDF.VCLCanvas.Pen.Width:=1;
    lPDF.VCLCanvas.MoveTo(100,100);
    lPDF.VCLCanvas.LineTo(500, 500);
    lPdf.VCLCanvas.TextOut( 300, 700,  'This is some text.');
    lPDF.VCLCanvas.Pen.Width:=2;
    lPDF.VCLCanvas.LineTo(900, 500);
    lPdf.VCLCanvas.TextOut( 300, 700,  'This is some text.');
    lPdf.SaveToFile('c:\Syntest.pdf');

  finally  
    lPdf.Free;
  end;
end;

Offline

#4 2011-04-18 17:48:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: Newbie

Hope it could help some newcomers to SynPdf.

Thanks!

Offline

Board footer

Powered by FluxBB