Einzelnen Beitrag anzeigen

philubb

Registriert seit: 27. Jun 2012
16 Beiträge
 
Delphi XE Enterprise
 
#1

Probleme mit dynapdf

  Alt 25. Okt 2012, 12:04
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ß
Miniaturansicht angehängter Grafiken
unbenannt.png  
  Mit Zitat antworten Zitat