You've already forked lazarus-ccr
PowerPDF Check In
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@585 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
75
components/powerpdf/Example/ConsoleProgramDemo/BatchPdf.dof
Normal file
75
components/powerpdf/Example/ConsoleProgramDemo/BatchPdf.dof
Normal file
@ -0,0 +1,75 @@
|
||||
[Compiler]
|
||||
A=1
|
||||
B=0
|
||||
C=1
|
||||
D=1
|
||||
E=0
|
||||
F=0
|
||||
G=1
|
||||
H=1
|
||||
I=1
|
||||
J=1
|
||||
K=0
|
||||
L=1
|
||||
M=0
|
||||
N=1
|
||||
O=1
|
||||
P=1
|
||||
Q=0
|
||||
R=0
|
||||
S=0
|
||||
T=0
|
||||
U=0
|
||||
V=1
|
||||
W=0
|
||||
X=1
|
||||
Y=0
|
||||
Z=1
|
||||
ShowHints=1
|
||||
ShowWarnings=1
|
||||
UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||
[Linker]
|
||||
MapFile=0
|
||||
OutputObjs=0
|
||||
ConsoleApp=1
|
||||
DebugInfo=0
|
||||
MinStackSize=16384
|
||||
MaxStackSize=1048576
|
||||
ImageBase=4194304
|
||||
ExeDescription=
|
||||
[Directories]
|
||||
OutputDir=
|
||||
UnitOutputDir=
|
||||
SearchPath=
|
||||
Packages=
|
||||
Conditionals=
|
||||
DebugSourceDirs=
|
||||
UsePackages=0
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=1041
|
||||
CodePage=932
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
241
components/powerpdf/Example/ConsoleProgramDemo/BatchPdf.dpr
Normal file
241
components/powerpdf/Example/ConsoleProgramDemo/BatchPdf.dpr
Normal file
@ -0,0 +1,241 @@
|
||||
{*
|
||||
*
|
||||
* BatchPdf.dpr
|
||||
*
|
||||
* To run this program, open command-prompt window and run this program with
|
||||
* filename parameter
|
||||
*
|
||||
* ex) BatchPdf.exe batchpdf.pdf
|
||||
*}
|
||||
|
||||
program BatchPdf;
|
||||
{$APPTYPE CONSOLE}
|
||||
uses
|
||||
SysUtils,
|
||||
Classes,
|
||||
PdfDoc,
|
||||
PdfTypes,
|
||||
PdfFonts,
|
||||
DB,
|
||||
DBTables;
|
||||
|
||||
var
|
||||
FDoc: TPdfDoc;
|
||||
FFileName: string;
|
||||
FOutFile: TFileStream;
|
||||
FPage: integer;
|
||||
FQuery: TQuery;
|
||||
|
||||
procedure TextOut(X, Y: Single; S: string);
|
||||
begin
|
||||
with FDoc.Canvas do
|
||||
begin
|
||||
BeginText;
|
||||
MoveTextPoint(X, Y);
|
||||
ShowText(S);
|
||||
EndText;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure DrawLine(X1, Y1, X2, Y2, Width: Single);
|
||||
begin
|
||||
with FDoc.Canvas do
|
||||
begin
|
||||
MoveTo(X1, Y1);
|
||||
LineTo(X2, Y2);
|
||||
Stroke;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure WriteHeader;
|
||||
var
|
||||
s: string;
|
||||
w: integer;
|
||||
begin
|
||||
// writing the headline of the pages
|
||||
with FDoc.Canvas do
|
||||
begin
|
||||
// setting font
|
||||
SetFont('Arial-BoldItalic', 16);
|
||||
|
||||
// printing text.
|
||||
TextOut(90, 770, 'Customer.DB');
|
||||
|
||||
SetFont('Arial-BoldItalic', 9);
|
||||
S := FormatDateTime('YYYY/MM/DD', Date);
|
||||
w := Round(TextWidth(S));
|
||||
|
||||
// writing header text.
|
||||
TextOut(530 - w, 770, S);
|
||||
|
||||
SetRGBStrokeColor($00008800);
|
||||
DrawLine(90, 765, 530, 765, 1.5);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure WriteFooter;
|
||||
var
|
||||
w: Single;
|
||||
s: string;
|
||||
begin
|
||||
with FDoc.Canvas do
|
||||
begin
|
||||
// Setting font and print text with center align
|
||||
SetFont('Times-Roman', 8);
|
||||
|
||||
DrawLine(90, 70, 530, 70, 1.5);
|
||||
|
||||
s := 'Page ' + IntToStr(FPage);
|
||||
w := TextWidth(s);
|
||||
|
||||
TextOut((PageWidth - w) / 2, 55, S);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure WriteRow(YPos: Single);
|
||||
var
|
||||
i: integer;
|
||||
s: string;
|
||||
begin
|
||||
// printing the detail lines
|
||||
with FDoc.Canvas do
|
||||
begin
|
||||
if not FQuery.Eof then
|
||||
begin
|
||||
TextOut(95, YPos - 15, FQuery.FieldByName('CustNo').AsString);
|
||||
|
||||
s := FQuery.FieldByName('Company').AsString;
|
||||
|
||||
// calculate the number of the charactor which can be contained in the
|
||||
// width of the frame.
|
||||
i := MeasureText(s, 130);
|
||||
TextOut(135, YPos - 15, Copy(s, 1, i));
|
||||
|
||||
s := FQuery.FieldByName('State').AsString +
|
||||
FQuery.FieldByName('City').AsString +
|
||||
FQuery.FieldByName('Addr1').AsString;
|
||||
|
||||
i := MeasureText(s, 175);
|
||||
TextOut(275, YPos - 15, Copy(s, 1, i));
|
||||
|
||||
TextOut(455, YPos - 15, FQuery.FieldByName('Phone').AsString);
|
||||
|
||||
FQuery.Next;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure WritePage;
|
||||
var
|
||||
i: integer;
|
||||
XPos, YPos: Single;
|
||||
begin
|
||||
with FDoc.Canvas do
|
||||
begin
|
||||
// writing the outline
|
||||
SetLineWidth(1.5);
|
||||
Rectangle(90, 80, 440, 680);
|
||||
Stroke;
|
||||
|
||||
// writing the horizontal lines.
|
||||
YPos := 760;
|
||||
SetLineWidth(0.75);
|
||||
for i := 0 to 32 do
|
||||
begin
|
||||
YPos := YPos - 20;
|
||||
MoveTo(90, YPos);
|
||||
LineTo(530, YPos);
|
||||
Stroke;
|
||||
end;
|
||||
|
||||
// writing the header of the text.
|
||||
SetLineWidth(1);
|
||||
SetFont('Times-Roman', 10.5);
|
||||
|
||||
XPos := 90;
|
||||
TextOut(XPos + 5, 745, 'NO.');
|
||||
|
||||
XPos := 130;
|
||||
DrawLine(XPos, 760, XPos, 80, 1);
|
||||
TextOut(XPos + 5, 745, 'Company');
|
||||
|
||||
XPos := 270;
|
||||
DrawLine(XPos, 760, XPos, 80, 1);
|
||||
TextOut(XPos + 5, 745, 'Address');
|
||||
|
||||
XPos := 450;
|
||||
DrawLine(XPos, 760, XPos, 80, 1);
|
||||
TextOut(XPos + 5, 745, 'Phone');
|
||||
|
||||
XPos := 530;
|
||||
DrawLine(XPos, 760, XPos, 80, 1);
|
||||
|
||||
// setting the font for the detail lines.
|
||||
SetFont('Arial', 10.5);
|
||||
end;
|
||||
|
||||
// printing the detail lines with 20 dot height.
|
||||
YPos := 740;
|
||||
for i := 0 to 32 do
|
||||
begin
|
||||
WriteRow(YPos);
|
||||
YPos := YPos - 20;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
if ParamCount > 0 then
|
||||
FFileName := ParamStr(1)
|
||||
else
|
||||
begin
|
||||
Writeln('Usage: bachpdf <pdf-filename>');
|
||||
Halt(2);
|
||||
end;
|
||||
|
||||
// create output-filestream.
|
||||
FOutFile := TFileStream.Create(FFileName, fmCreate);
|
||||
|
||||
FPage := 1;
|
||||
|
||||
// create TQuery object and set properties.
|
||||
FQuery := TQuery.Create(nil);
|
||||
with FQuery do
|
||||
try
|
||||
Writeln('BatchPdf opening database..');
|
||||
DatabaseName := 'DBDEMOS';
|
||||
SQL.Text := 'SELECT CustNo, Company, State, City, Addr1, Phone from Customer';
|
||||
Open;
|
||||
|
||||
// create TPdfDoc object.
|
||||
Writeln('BatchPdf creating document..');
|
||||
FDoc := TPdfDoc.Create;
|
||||
with FDoc do
|
||||
try
|
||||
// create a new document.
|
||||
NewDoc;
|
||||
|
||||
// printind page from the result of the query.
|
||||
while not FQuery.Eof do
|
||||
begin
|
||||
AddPage;
|
||||
WriteHeader;
|
||||
WritePage;
|
||||
WriteFooter;
|
||||
inc(FPage);
|
||||
end;
|
||||
|
||||
// save the pdf-document to the file-stream.
|
||||
Writeln('BatchPdf saving document..');
|
||||
FDoc.SaveToStream(FOutFile);
|
||||
finally
|
||||
FDoc.Free;
|
||||
end;
|
||||
|
||||
Close;
|
||||
Writeln('BatchPdf end..');
|
||||
finally
|
||||
Free;
|
||||
FOutFile.Free;
|
||||
end;
|
||||
|
||||
end.
|
BIN
components/powerpdf/Example/ConsoleProgramDemo/BatchPdf.res
Normal file
BIN
components/powerpdf/Example/ConsoleProgramDemo/BatchPdf.res
Normal file
Binary file not shown.
Reference in New Issue
Block a user