Einzelnen Beitrag anzeigen

tom_po

Registriert seit: 5. Feb 2006
137 Beiträge
 
Delphi 7 Enterprise
 
#14

Re: mit pdf-Tool nur Teil einen Stringgrid drucken

  Alt 10. Mai 2006, 07:42
Hallo Marabu, du hast mir ja so sehr geholfen beim Ausdruck mit den labels, der Code sieht jetzt so aus wie folgt.
wenn ich jetzt 3 labels nebeneinander auf der DIN A4-Seite möchte, was muss ich in der Funktion ändern (ausser den Positionen der einzelnen Angaben)

Delphi-Quellcode:
function LabelToPage(pt: Tpoint; index: Integer): TPoint;
const
  PageLeft = 20;
  PageTop = 30;
  LabelWidth = 600; //Original-Label-Masse
  LabelHeight = 120;
begin
  Result := Point(
              pt.X + PageLeft + (index mod 2) * LabelWidth,
              pt.Y + PageTop + (index div 2) * LabelHeight
            );
end;

procedure Tlote.Button1Click(Sender: TObject);
const
  ptArtikel: TPoint = (X: 0; Y: 0); // Werte für DIN A4
  ptFarbe: TPoint = (X: 150; Y: 0);
  ptColumn2: TPoint = (X: 400; Y: 0);
  ptOrder: TPoint = (X: 0; Y: 50);
  ptCode: TPoint = (X: 125; Y: 32);
  ptColumn0: TPoint = (X: 285; Y: 50);
  ptColumn1: TPoint = (X: 415; Y: 50);
 var
  iRow, iLabel: Integer;
begin
  deletetmppdf;
  with printpdf1 do
  begin
    FileName:=gettemppathd+'tmppdf'+Inttostr(random(5000))+'.pdf';
    PageWidth:=1224; // Origanl-DIN A4
    PageHeight:=1725; // Origanl-DIN A4
    BeginDoc;
    Font.Name:=poTimesBoldItalic;
    Font.Size:=24; //alt 24
  end;

  iLabel := 0;
  with StringGrid1, printpdf1 do
    for iRow := 0 to 15 do
      if Trim(Cells[1, iRow+1]) <> 'then
      begin
        with LabelToPage(ptArtikel, iLabel) do
          TextOut(X, Y, 'Artigo: ' + lote.Artikel.Text);
        with LabelToPage(ptFarbe, iLabel) do
          TextOut(X, Y, 'Côr: ' + Cells[3, FixedRows + iRow]);
          //TextOut(X, Y, 'Côr: ' + lote.Farbe.Text); //von DB
        with LabelToPage(ptColumn2, iLabel) do
          TextOut(X, Y, 'Tam.: ' + Cells[2, FixedRows + iRow]);
        with LabelToPage(ptOrder, iLabel) do
          TextOut(X, Y,'N.P.: '+lote.order.text);
        with LabelToPage(ptCode, iLabel) do
          pdfcodedrucken(X, Y, lote.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
          EndDoc;
         end;

  ShellExecute(Application.Handle, 'open', PChar(printpdf1.FileName), nil, nil, SW_NORMAL);

end;
  Mit Zitat antworten Zitat