procedure TForm1.FormCreate(Sender: TObject);
var
//TXT
TXT : TStringlist;
I : integer;
searchResult : TSearchRec;
//PDF
counter : integer;
switch :
string;
pdffile:
string;
PDF : TPDFDocumentGDI;
Page : TPDFPage;
Image : TBitmap;
begin
// ReportMemoryLeaksOnShutdown := True;
TXT := TStringList.Create;
try
findfirst(ExtractFilePath(ParamStr(0)) + '
*.txt', faAnyFile, searchResult);
TXT.LoadFromFile(searchResult.
Name);
pdffile := copy(searchResult.
Name, 1, length(searchResult.
Name)-3) + '
pdf';
PDF := TPDFDocumentGDI.Create();
try
PDF.Info.Author := '
Company Name';
PDF.Info.CreationDate := now;
PDF.Info.Subject := '
Subject';
Pdf.Info.Title := '
Title';
//--
Page := PDF.AddPage;
Page.PageLandscape := False;
PDF.DefaultPaperSize := psA4;
//--------Seite1-Start
//--------Header-Start
Pdf.VCLCanvas.Font.Color := cLHotLight;
PDF.VCLCanvas.Font.Size := 10;
PDF.VCLCanvas.TextOut(325, 25, '
Title');
Pdf.VCLCanvas.Font.Color := clBlack;
//--------Header-Ende
PDF.VCLCanvas.Font.Size := 20;
PDF.VCLCanvas.Font.Style := [fsBold, fsUnderline];
PDF.VCLCanvas.TextOut(325, 65, '
Headline');
PDF.VCLCanvas.Font.Size := 14;
PDF.VCLCanvas.Font.Height:= PDF.VCLCanvas.Font.Height + 5;
PDF.VCLCanvas.Font.Style := [];
PDF.VCLCanvas.Font.
Name := '
Courier New';
TXT[1] := copy(TXT[1], 23, length(TXT[1]));
for I := 1
to TXT.Count - 1
do
begin
if (TXT[I] <> '
')
and (I <> 2)
then
begin
if I = 1
then
PDF.VCLCanvas.Font.Color := clRed
else
PDF.VCLCanvas.Font.Color := clBlack;
PDF.VCLCanvas.TextOut(75, 115 + (I * 14), TXT[I]);
end;
end;
//--------Footer-Start
Pdf.VCLCanvas.Font.Color := cLHotLight;
PDF.VCLCanvas.Font.Size := 10;
PDF.VCLCanvas.Font.Height:= PDF.VCLCanvas.Font.Height - 5;
PDF.VCLCanvas.TextOut(225, 1085, '
Erstellt am: ' + datetimetostr(now));
Pdf.VCLCanvas.Font.Color := clBlack;
//--------Footer-Ende
//--------Seite1-Ende
//--------PDF-Ende
PDF.SaveToFile(pdffile);
finally
PDF.Free;
shellexecute(
handle, '
open', PChar(pdffile),'
','
',SW_Normal);
end;
finally
deletefile(searchResult.
Name);
TXT.Free;
Application.Terminate;
end;
end;