WPCubed Product Support

Bilder werden nicht gespeichert

Hallo,
ich nutze WPTools für einen Briefgenerator, bei dem Platzhaltergrafiken bei der Serienbrieferstellung über*ObjCallback* mit den richtigen Grafiken versehen werden. Das klappt perfekt, aber diese Grafiken werden nicht gespeichert. Wenn ich das Dokument speichere und später wieder aufrufe, ist wieder nur die Platzhaltergrafik enthalten. Manuell eingefügte Grafiken werden perfekt gespeichert. Was mache ich falsch?

procedure TwpMain.ObjCallback(RTFData: TWPRTFDataCollectionBase; RTFDataBlock: TWPRTFDataBlock; Par: TParagraph;
  obj: TWPTextObj;
  param: TObject);
var
  i, j, k: Integer;
  f: extended;
  s, Typ, title, sx, sy, option, serie: string;
  hasEvent: Boolean;
  w, h, w0, h0: Integer;
  fw, fh: extended;
begin
  if obj.IsImage then begin
    // Bilder
    s := uppercase(obj.ObjRef.url);
    if (s = 'PATPIC.JPG') or (pos('CHART', s) = 1) then
      if fileexists(tempdir + s) then
        try
          // load new file into placeholder
          obj.ObjRef.LoadFromFile(tempdir + s);
          obj.ObjRef.Transparent := true;
          obj.ObjRef.GetContentsWH(w, h);
          w0 := obj.width;
          h0 := obj.height;
          fw := w0 / w;
          fh := h0 / h;
          // use the smaller factor ta make sure it fits in
          if fw > fh then
            fw := fh;
          obj.width := round(w * fw);
          obj.height := round(h * fw);
          // center it in the orignal area
          obj.RelX := obj.RelX + (w0 - obj.width) div 2;
          obj.RelY := obj.RelY + (h0 - obj.height) div 2;
        except
          obj.ObjRef.Picture.Assign(mainForm.imgEmpty.Picture.Graphic);
        end
      else
        obj.ObjRef.Picture.Assign(mainForm.imgEmpty.Picture.Graphic);
  end;
#1 ♥ 0
3.9k Views 2 users read 2 min

As I found the answer on my own I post in english to make the solution available to more people.

I replaced

... obj.ObjRef.LoadFromFile(tempdir + s);...

by

...
obj.ObjRef:=wpLoadObjectFromFile(wp,tempdir + s,false);
...

and now the new pictures are saved by wp.saveToFile(...).

#2 ♥ 0
support

Hi,

I may explain:

With the first, not working code it was possible that always the same TWPObject instance (the placeholder) was filled with new data, the second code will create a new instance was created for each placeholder.

Many TWPTextObj instances may point to the same TWPObject.

Julian

#3 ♥ 0
This category is archived. No new posts are possible.