Registriert seit: 6. Apr 2005
10.109 Beiträge
|
Re: mit pdf-Tool nur Teil einen Stringgrid drucken
7. Mai 2006, 09:17
Hallo,
wenn du deinen Code besser organisierst, dann entkommst du vielleicht dem maintenance blues:
Delphi-Quellcode:
function LabelToPage(pt: Tpoint; index: Integer): TPoint;
const
PageLeft = 20;
PageTop = 40;
LabelWidth = 600;
LabelHeight = 120;
begin
Result := Point(
pt.X + PageLeft + (index mod 2) * LabelWidth,
pt.Y + PageTop + (index div 2) * LabelHeight
);
end;
procedure TDemoForm.Button1Click(Sender: TObject);
const
ptArtikel: TPoint = (X: 0; Y: 0);
ptFarbe: TPoint = (X: 150; Y: 0);
ptColumn2: TPoint = (X: 400; Y: 0);
ptOrder: TPoint = (X: 0; Y: 50);
ptCode: TPoint = (X: 115; Y: 32);
ptColumn0: TPoint = (X: 260; Y: 50);
ptColumn1: TPoint = (X: 400; Y: 50);
var
iRow, iLabel: Integer;
pdf: TCanvas;
Artikel, Farbe, Order: TEdit;
begin
deletetmppdf;
with printpdf1 do
begin
FileName:=gettemppathd+'tmppdf'+Inttostr(random(5000))+'.pdf';
PageWidth:=1224;
PageHeight:=1725;
BeginDoc;
Font.Name:=poTimesBoldItalic;
Font.Size:=24;
end;
iLabel := 0;
with StringGrid1, printpdf1 do
for iRow := 0 to 7 do
if Trim(Cells[FixedCols, iRow]) <> '' then
begin
with LabelToPage(ptArtikel, iLabel) do
TextOut(X, Y, 'Artigo: ' + Artikel.Text);
with LabelToPage(ptFarbe, iLabel) do
TextOut(X, Y, 'Côr: ' + Farbe.Text);
with LabelToPage(ptColumn2, iLabel) do
TextOut(X, Y, 'Tam.: ' + Cells[2, FixedRows + iRow]);
with LabelToPage(ptArtikel, iLabel) do
TextOut(20,90,'N.P.: '+order.text);
with LabelToPage(ptArtikel, iLabel) do
{pdfcodedrucken(X, Y, Order.Text, False)};
with LabelToPage(ptColumn0, iLabel) do
TextOut(X, Y, 'N°./Lo: ' + Cells[0, FixedRows + iRow]);
with LabelToPage(ptColumn1, iLabel) do
TextOut(X, Y, 'Peç/Lo: ' + Cells[1, FixedRows + iRow]);
Inc(iLabel);
end;
with printpdf1 do
begin
LineWidth := 2;
DrawLine(0, 530, 1224, 530);
EndDoc;
end;
ShellExecute(Application.Handle, 'open', PChar(printpdf1.FileName), nil, nil, SW_NORMAL);
end;
Getippt und nicht getestet.
Freundliche Grüße vom marabu
|