LoadFromStream (s, 'RTF') - one line, one paragraph

  • Hello
    The version is 6.29.

    I am unsuccessful loading a stream of a one line paragraph with tab stops at the top of my document.

    The code below works perfectly fine as long as the TemplateRTFString below contains more than one line of text; The template is placed at the top of the current document along with the templates tab stops.

    However, if TemplateRTFString only contains one line of text (one paragraph \par at the end), the template placed at the top of the current document is without its original tab stops, instead its assuming the tab stops of the current document.

    Code
    CPPosition := 0;	InputString(#13);	CPPosition := 0;	s := TStringStream.Create (TemplateRTFString);  	myCustRtfEdit.LoadFromStream( s, 'RTF' );

    The resulting output would look like this:

    Code
    \pard\plain\wpparid0\plain\f1\fs24\cf0\tab A one line, one paragraph template\par\plain\f0\fs22\cf0 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \par


    If the template contained more than one line, the resulting output would look similar to this, correctly with the tab stops:

    Code
    \pard\plain\tx2895\plain\f1\fs24\cf0\tab A two line, two paragraph template\par\tx2895\plain\f1\fs24\cf0 This is the second template line and paragraph\par\pard\plain\f0\fs22\cf0 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \par

    Would I am trying to achieve with 1 line, 1 paragraph templates would look similar to this containing the tab stop information on the 1st line:

    Code
    \pard\plain\tx2895\plain\f1\fs24\cf0\tab A one line, one paragraph template\par\pard\plain\f0\fs22\cf0 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \par


    I have tried variations of LoadFromString and LoadFromStream, for example:

    Code
    CPPosition := 0;
    	s := TStringStream.Create (Template.MemoLines.Text);
    
    	Memo.LoadFromStream ( s,      // the stream
    						  true,   // insert the text, don't clear existing text
    						  'RTF',
    						  true    // don't split par
    						  );



    The result worked in regards to the tab stops carrying over to the current document
    but an extra empty paragragraph is left at the top of the current document.

    Can you provide assistance?

    Also, I am very near complete with the migration from v3 to v6 and am extremely happy with the results. The formatting and printouts of the documents, especially with tables, borders indents, tabs is working much better than the older version. Thank you.

  • Zitat von wpsupport

    The paragraph attributes are applied in RTF on the closing \par when you insert text. You can try to load in a clear TWPRichText and copy the paragraph attributes.

    I'm not sure I understand 100% right now but let me absorb this and see what can be changed.

    Thank you.