unit DoPDFU;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, ShellAPI, Jpeg, SynPDF;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
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 := '
Name.pdf';
PDF := TPDFDocumentGDI.Create();
try
PDF.Info.Author := '
Autor';
PDF.Info.CreationDate := now;
PDF.Info.Subject := '
Bla';
Pdf.Info.Title := '
Bla';
//--
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, '
Header');
Pdf.VCLCanvas.Font.Color := clBlack;
//--------Header-Ende
PDF.VCLCanvas.Font.Size := 20;
PDF.VCLCanvas.Font.Style := [fsBold, fsUnderline];
PDF.VCLCanvas.TextOut(325, 65, '
Überschrift');
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;
end.