How to identify an image using a property

  • Using XE7 with WPT 7.21
    I want to identify one of several images in a document for providing editing functionality for this image.
    So, I insert the original image into the document using the following code, and try to keep some identification of that image using the properties FileName, Extra, ObjTag and Tag

    Code
    TextObject := TWPOImage.Create(WPRichText1.Memo.RTFData);  TextObject.LoadFromFile(sFle);TextObject.FileName := 'Paint';      TextObject.Extra := 'Paint';TextObject.ObjTag := 6969;TextObject.Tag := 6969;WPRichText1.TextObjects.Insert(TextObject);

    If I remain in the current editing sesión of the document, I can retrieve those properties, but if I save the document, and later open again, then those properties are not saved in the RTF.
    I want to use the following code, but any of the FileName, Extra, ObjTag and Tag has any value.

    So, what property of the actual object must I use to persist a value for identifying that image

    • Offizieller Beitrag

    What becomes saved depends on the file format you use.

    The best option is usually to not embed the images int the document and rather just save a link to that. To do so use the property StreamName and the event OnHTTPRequestImage to load it back. You can also load it later in the OnTextObjPaint event which makes it possible to load the image when it is required for display, which can be much later. In such case you can reassign any of the properties.

    If you prefer to embed it, you can use txtobj.Name and txtobj.Source as identifier. Both are saved to RTF. Note, this are properties of the alias TWPTextObj, not of the TWPOImage.

  • I am saving a bitmap created in the same application using standard Delphi components.

    I insist in to embed the image into the rtf, so, following your suggestions, I am using this code that now is working:

    Code
    TextObject := TWPOImage.Create(WPRichText1.Memo.RTFData);
      TextObject.LoadFromFile(sFle);
      WPRichText1.TextObjects.Insert(TextObject);
      iK := WPRichText1.TextObjects.ObjCount;
      WPRichText1.TextObjects.ObjList[iK-1].Name := 'Paint';

    While testing this solution, using .Source property instead of .Name, I can see the image on screen, but once the RTF document is saved, when I reopen, the image is blank, perhaps Source is intended to content another type of information.

  • I assign "Source" instead of "Name" in the last code above. That is

    Zitat

    WPRichText1.TextObjects.Insert(TextObject);
    iK := WPRichText1.TextObjects.ObjCount;
    WPRichText1.TextObjects.ObjList[iK-1].Source:= 'Paint';

    Doing so, it seems that the image is saved blank.

    If in the above code, I use "Name", instead "Source", then it is working correctly.