Posts by siva shankar

    Im new to delphi, so its hard for me to create a similar test project. I understood its difficult for your team without sample test project but kindly guide me. After the property TWPRichText.WriteObjectMode is changed from wobStandardNoBinary to wobRTF.

    1) TWPRichText.SaveToFile() --> saves RTF file with images but not all images.

    -> Only Images which are loaded through InputMergeField (image added at head and end of document) are displayed.

    -> other images added at event OnRequestHTTPImage are not displayed. In RTF document getting message as "The linked image cannot be displayed. The file may have been moved, renamed or deleted. Verify that link points to correct file and location "


    2)Tried TWPRichText.Print() before SaveToFile() method and here all the images are printed


    3) TriedTWPRichText.AsANSIString('RTF-nobinary');


    \pard\plain\plain\f0\fs24{\field{\*\fldinst{MERGEFIELD logo-Header \{6A7A1AD2-A099-4006-AD33-4BFE17803F4A\}}}{\*\wpfldparam{logo-Header}}{\fldrslt{{\pict\jpegblip\picw12240\pich15840\picwgoal12240\pichgoal15840 --> After this encoded image value is present


    \pard\plain\s0\plain\fs24

    {\field{\*\fldinst{INCLUDEPICTURE "{587CEBEE-A031-40F3-943E-329D4A3534DC}" MERGEFORMAT \\d \\w1920 \\h2880 \\pm1 \\px9600 \\py0 \\pw0}}}\par

    \pard\plain\par --> No encoded image value. just empty after this


    \plain\fs14{\field{\*\fldinst{MERGEFIELD logo-Footer \{18E1A3CC-EEC9-473F-87E9-F5A05C666A1C\}}}{\*\wpfldparam{logo-Footer}}{\fldrslt{\f0\fs24{\pict\jpegblip\picw28305\pich1065\picwgoal28305\pichgoal1065 --> After this encoded image value is present


    4) In debug mode, value of TextObject(Images)

    (280, wpobjImage, $D565F20, [], [], $BEB0020, -1, '', '', '', nil, nil, '', 0, 0, 0, 12240, 15840, (nil,nil), (nil,nil), (nil,nil), 0, 0, wpwrAutomatic, nil)


    (534, wpobjImage, $D566C40, [wpobjRelativeToParagraph], [], $1437E920, -1, '', '', '', nil, nil, '', 0, 0, 0, 1920, 2880, (nil,nil), (nil,nil), (nil,nil), 9600, 0, wpwrAutomatic, nil) --> Missing image


    (485, wpobjImage, $D566970, [], [], $14957F80, -1, '', '', '', nil, nil, '', 0, 0, 0, 10930, 1042, (nil,nil), (nil,nil), (nil,nil), 0, 0, wpwrAutomatic, nil).


    Is there any other values or details you need, kindly let me know.

    Tried today,

    1) WPRichText.Print() -> Here it prints the document with images.


    2) Also in PDF export the images are exported with PDF Export component.

    Consider below sample code for reference

    var

    pdf : TWPPDFExport;

    pdfStream : TMemoryStream;

    pdfString : string;

    begin

    pdfStream := TMemoryStream.Create;

    WPDF_Start('', ''); -> Application related strings are passed

    pdf.InMemoryMode := True;

    pdf.Stream := pdfStream;

    pdf.Source := WPRichText;

    pdf.FontMode := wpEmbedSymbolTrueTypeFonts;

    pdf.CompressStreamMethod := wpCompressFlate;

    pdf.JPEGQuality := wpJPEG_50;

    pdf.Print;

    pdfString := MemoryStreamToString(pdfStream)


    Is there any component like TWPPDFExport for exporting in RTF format?

    Yes Images are present in document.

    -->Consider below sample code for reference


    WPRichTextDocument (TWPRichText)--> Images are added in OnRequestHTTPImage event ( procedure WPRichTextRequestHTTPImage )


    CreateRtfDocument(WPRichTextDocument);


    procedure CreateRtfDocument(WPRichText : TWPCustomRtfEdit)

    {

    begin


    WPRichText.OnRequestHTTPImage := WPRichTextRequestHTTPImage;// Tried this now but still no images are add in the documents

    WPRichText.SaveToFile('D:\RTF\SampleDocument.rtf',FALSE,'RTF-nobinary');

    WPRichText.SaveToFile('D:\RTF\SampleDocument1.rtf',FALSE,'RTF');

    end

    }

    Need Clarification:

    While passing WPRichTextDocument as argument whether the images also will be passed or not?

    Is there any way to directly call OnRequestHTTPImage event, so that images may added in WPRichText.

    var

    listImage : TWPTextObjList;

    count:Integer;

    WPRichText : TWPCustomRtfEdit //( Passed in function call)

    Record : IXMLNode;



    begin


    listImage := TWPTextObjList.Create;

    WPRichText.ImageGetList(listImage,true);

    count:=listImage.Count; //Returns Image count



    Record.ChildNodes['RTF'].text := AWPRichText.RtfText.AsString;

    Record.ChildNodes['RTF1'].text :=AWPRichText.AsANSIString('RTF');


    //When saved as file, the above two node has only text and not images

    // 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

    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.