Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Algorithmen, Datenstrukturen und Klassendesign (https://www.delphipraxis.net/78-algorithmen-datenstrukturen-und-klassendesign/)
-   -   Probleme mit dynapdf (https://www.delphipraxis.net/171195-probleme-mit-dynapdf.html)

philubb 25. Okt 2012 11:04

Probleme mit dynapdf
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo

ich verwende im Geschäft dynapdf um Reports zu erstellen.

Nun möchte ich einen Barcode in eine Celle einer erstellen Tabelle, als Bild (Bitmap) einfügen.
Das funktioniert auch so weit.

Delphi-Quellcode:
 ....
   
 //Pfad wo Bitmap später stehen soll
  BCPfad := 'C:\EDM\VIA\Barcode'+cdsDruck.FieldByName('AUFTRAG_NR').AsString + '.bmp';
 //Barcode erstellen
  CreateBarcode(BCPfad,cdsDruck.FieldByName('AUFTRAG_NR').AsString);
  if BCPfad <> '' then
  begin
    //Schneidet die Zahlen, die unter dem Barcode stehen ab
    BitmapAnpassen(BCPfad);
    //Bitmap in TImage Komponente laden
    imgBarcode.Picture.LoadFromFile(BCPfad);
    //Bild in die entsprechende Zelle setzen
    Auftrag.Cells[4,zeile+32+i].Image := imgBarcode;
  end;

  procedure TFormVIA.CreateBarcode(var BCPfad:String; Code:String);
var
  bmp:TBitmap;
begin
  try
    Barcode1d1.Code:=Code;
    bmp := TBitmap.create();
    bmp.height := 100;
    bmp.width := 250;
    barcode1d1.paintBarcode(bmp.Canvas);
    bmp.SaveToFile(BCPfad);
    bmp.Free;
  except
    on e:Exception do
      //showmessage(e.message);
      BCPfad := '';
  end;
end;

procedure TFormVIA.BitmapAnpassen(Pfad:String);
var
  SourceBitmap:TBitmap;
  TargetBitmap:TBitmap;
  Cut : TRect;
begin
  SourceBitmap := TBitmap.Create;
  TargetBitmap := TBitmap.Create;
  try
    SourceBitmap.LoadFromFile(Pfad);
    Cut.Left := 10;
    Cut.Top := 20;
    Cut.Right := 130;
    Cut.Bottom := 70;

    TargetBitmap.Width := Cut.Right - Cut.Left;
    TargetBitmap.Height := Cut.Bottom - Cut.Top;

    BitBlt(TargetBitmap.Canvas.Handle,0,0,Cut.Right,Cut.Bottom,SourceBitmap.Canvas.Handle,Cut.Left,Cut.Top,SRCCOPY);
    SourceBitmap.Canvas.Refresh;

    if FileExists(Pfad) then
      DeleteFile(Pfad);

    TargetBitmap.SaveToFile(Pfad);
  finally
    SourceBitmap.Free;
    TargetBitmap.Free;
  end;
end;
Das klappt alles.
Aber die Celle passt sich nicht, an die größe des Bildes an. Woran kann das liegen?

Hab auch schon nach Lösungen im Internet gesucht, aber finde kaum verwendbare Informationen. Vielleicht hat mir ja auch jemand ein Tutorial.

Gruß


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:32 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz