Text are placed under image

  • Hi ,


    The document with images are loaded in TWPRichText component. Sometimes for some images alone, the text are placed under the image. How to avoid this behavior. The images are loaded through TWPTextObj in WPRichTextRequestHTTPImage method. Tried TTextObjWrap, TTextObjAlign property of TWPTextObj but still couldn't able to get the desired behavior. Kindly provide us some inputs to proceed further.

  • // Document is loaded as follows

    WPRichText.TextSaveFormat := 'WPT';

    WPRichText.TextLoadFormat := 'WPT'; WPRichText.CPPosition := 0;

    wprichtext2.TextSaveFormat := 'WPT';

    wprichtext2.TextLoadFormat := 'AUTO';

    wprichtext2.CPPosition := 0;

    // populating the text

    WPRichText.AsString; // Header, Details are populated

    wprichtext2.AsString; // other details are populated

    WPRichText.SelectionAsString := wprichtext2.AsString;

    // Margin is set

    WPRichText.Header.LeftMargin

    WPRichText.Header.RightMargin

    WPRichText.Header.bottomMarginc

    WPRichText.Header.topMargin

    // Return the complete document

    result := WPRichText.AsString;


    In WPRichTextRequestHTTPImage method

    Graphic := TMemoryStream.Create;

    //Graphic is loaded from database i.e SaveBlobDataToStream(TBlobField(qryGraphic.fieldbyname('graphic')), Graphic);.

    TextObject.LoadObjFromStream('jpg',Graphic); //

    TextObject.width := intWidth;

    TextObject.Height := intHeight;

    strGUID := URL;

    TextObject.ObjRef.StreamName := strGUID;

    TextObject.ObjRef.Extra := Document_GUID;


    Let me know if i need to provide further inputs

  • Instead of this


    WPRichText.SelectionAsString := wprichtext2.AsString;


    I would use a memory stream. You have conversions to strings here which can have unwanted effects and loss in performance.


    When you do


    TextObject.LoadObjFromStream('jpg',Graphic); //


    you can also modify the ObjModes to make the image character dependent or you can change the wrap mode.


    Of course the event will be only called for linked images which do not embed data. Usually they are used by RTF or HTML code.

  • This is a bit vague - if you have a demo project using WPTools 8 which shows the unwanted effect I check it out.


    Maybe you use tables - I could imagine text can be under an image if it is linked in a different cell - but this is more a problem with the document than a wptools issue.


    You can send example files and demo projects (sourcecode, no binary) to support@wptools.de