FastAppendText dosen't copy graphics

  • Hi! I have a text saved by wptools. In that text, there is a special tag, wich must be replaced by an image (User signagture).

    The code I'm using:

    When I run the program, it works great! The wprich passed to that procedure shows the image perfectlly. But, when I use FastAppendText, or CopyToClipboard and PasteFromClipboard, to copy that text to the end of another wprich object, the image is not copied!

    I'm doing something wrong?? Help me!!

    Thanks

    • Offizieller Beitrag

    Hi,

    Instead of
    wpEditor.TextObjects.InsertCopy(Image1.Picture.Graphic);

    you should do this:

    TextObject := nil; // at the start

    then load the graphic from DB

    TextObject.FileExtension := 'JPG';
    TextObject.LoadFromStream(BlobStream)

    the insert that image using you Finder.Next loop

    wpEditor.TextObjects.Insert( TextObject )

    Do not free that TextObject unless it has not been inserted!

  • Julian, I tried some code using your hints. But, I'm getting an "Accsses Violation" when I call

    Code
    TextObject.FileExtension := 'JPG';

    Tried to create the TextObject variable before it, but don't know how to do this.

    Can you help me?

    Thanks

    • Offizieller Beitrag

    TextObject is defined but not created in your code.

    TextObject := TWPOImage.Create(wpEditor);
    TextObject.FileExt := 'JPG';
    TextObject.LoadFromStream(...)

    now you can insert that TextObject using

    wpEditor.Finder.ToStart;
    didInsert := FALSE;
    while wpEditor.Finder.Next(TagImagem) do
    begin
    wpEditor.CPPosition := wpEditor.Finder.FoundPosition;
    wpEditor.Finder.FoundText := '';
    wpEditor.TextObjects.Insert(TextObject);
    didInsert := TRUE;
    end;

    if not didInsert then TextObject.Free;


    Julian