Changing graphic on print/preview

  • How can I change a picture when the report/labels are being generated. Which event should I use and how should I do this?

    At label design time I allow the user to insert a dummy picture (as a placeholder) and I set the objName to '{GRAPHIC}' for example.

    When the report/label is run/previewed I can test in the OnBeforeGraphicPrint or OnCreateGraphic event of the label if the objName is {GRAPHIC} and if so, I would like to replace the picture or draw on the canvas of that graphic.

    How can I do that?

    • Offizieller Beitrag

    procedure TForm1.FDUpdateData(Sender: TObject; Graphic: TWPFGGraphic;
    const ObjName: String; var Done: Boolean);
    begin
    if (ObjName= '{DATAFIELD}') and
    (Graphic is TWPFGGraphicPicture) then
    begin
    TWPFGGraphicPicture( Graphic ).LoadFromFile('a new name.bmp');
    end;
    end;

    On UpdateData is triggered for all objects which have a name after the
    procedure FD.UpdateData(AllPages: Boolean) was called.