This is a migrated thread and some comments may be shown as answers.

Section Break problem

1 Answer 74 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 16 Dec 2012, 11:37 PM
Hi,
I have a document with content wrapped inside a content annotation.

Within the content, i inserted a section break. Upon insertion, i noticed the following:

  • The editor is prepending the new section with an empty paragraph.
  • For the last section, the page orientation is not preserved.

In my code I have  RadDocument, and converted each contents within the annotation selection to small radDocument objects.

var fragment = selection.CopySelectedDocumentElements(false);

            //convert fragment to radDocument then copy the style of the first p
            var fragmentDocument = templateRadDocument.CreateDeepCopy() as RadDocument;

convert the fragmentDocument to OpenXML

In the converted RadDocument, it doesnt seem to preserve the correct page orientation for the last section.


  <?xml version="1.0" encoding="utf-8" ?> 
- <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
- <w:body>
- <w:p>
- <w:pPr>
  <w:rPr /> 
- <w:sectPr>
  <w:type w:val="nextPage" /> 
  <w:pgSz w:w="15840" w:h="12240" w:orient="landscape" /> 
  <w:pgMar w:bottom="1425" w:top="1425" w:right="1425" w:left="1425" /> 
  </w:sectPr>
  </w:pPr>
- <w:r>
  <w:rPr /> 
  <w:t xml:space="preserve">Content on before section break</w:t> 
  </w:r>
  </w:p>
- <w:p>
- <w:pPr>
  <w:rPr /> 
  </w:pPr>
- <w:r>
  <w:rPr /> 
  </w:r>
  </w:p>
- <w:p>
- <w:pPr>
  <w:rPr /> 
  </w:pPr>
- <w:r>
  <w:rPr /> 
  <w:t xml:space="preserve">content after</w:t> 
  </w:r>
  </w:p>
- <w:sectPr>
  <w:type w:val="nextPage" /> 
  <w:pgSz w:w="12240" w:h="15840" /> (This should also be landscape..)
  <w:pgMar w:bottom="1425" w:top="1425" w:right="1425" w:left="1425" /> 
  </w:sectPr>
  </w:body>
  </w:document>


1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 20 Dec 2012, 07:31 AM
Hi Jack,
To your questions:
  • If you insert a section break at the end of the document, there will be an empty paragraph in the newly created section. However, if you try inserting two sequential times a section break at the same place in the middle of a document, the result will be different. The cause of this is that the last block element in a RadDocument has to be a paragraph. It also cannot be deleted and if you try creating a new document in our online demo and enable the paragraph symbols, you'll see that there is a blank paragraph already.
  • The CopySelectedDocumentElements() method returns a document fragment. As DocumentFragment is intended to be inserted in another document, the last section in it inherits its properties from the "large" document. In your case, if I understand correctly, these are the default property values as you create a new RadDocument. The behavior is such by design. To work around it you can try copying the Section properties (more info is available here) and apply them on the last section in your newly created document.

I hope this is helpful! Do not hesitate to get back to us if you need additional assistance.
 
All the best,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Jack
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or