TwpTextObj for images and Source-Property

  • Hi,

    I'm trying to add a MailMerge-Function for 2D-barcodes. For that I add Images to the WP-Document and set some properties similar to a MailMerge-Field to resolve them programatically when I'm printing the document.

    To distinquish normal pictures from "MailMerge-Barcode-Pictures" I want to set the TWpTextObj.Source (to use a command similar to MailMerge-Fields) and the Params to store a default text used for the barcode.

    I use the following code to add the Image:

    Code
    // Create a TWPOImage with a certain bitmap    BarcodeObject := TWPOImage.CreateImage(welRichText.Memo.RTFData, BarcodeBitmap);    BarcodeObject.WriteRTFMode := wobBoth;    BarcodeObject.WidthTW := MulDiv(BarcodeBitmap.Width, 1440, WPScreenPixelsPerInch);    BarcodeObject.HeightTW := MulDiv(BarcodeBitmap.Height, 1440, WPScreenPixelsPerInch);    X := welRichText.GetXPositionTw;    BarcodeTextObj := welRichText.TextObjects.Insert(BarcodeObject);    if BarcodeTextObj <> nil then    begin      // Speichern der Werte zum verknüpfen der Grafik mit dem Mailmerge:      BarcodeTextObj.Name := AFullFieldName;      BarcodeTextObj.Params := ASampleText;      BarcodeTextObj.Source := MFB_Barcode_Ident[ABarcodeType];      BarcodeTextObj.Mode := BarcodeTextObj.Mode + [wpobjRelativeToParagraph];

    When I check the parameters immediatly after adding the object everything is fine.

    After saving the document to a stream with

    Code
    welRichText.SaveToStream(Stream);

    and reloading it again into the editor the Params- and Source-Property of the TwpTextObj are empty.

    What do I need to do that those properties are also saved for a TwpTextObj with the ObjType wpobjImage?

    Thank you for your help
    Daniel

  • Thanks for the help. I now tried to store it with the WPTools-Format and with that format it works as expected.

    As I just stored the documents internally in a database: Is there any disadvantage of using the WPTools-Format? I could not find any information on pros and cons of different formats specially between RTF and WPTools

    Daniel