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

Call InsertPageBreak and then "System.StackOverflowException"

3 Answers 85 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Dario
Top achievements
Rank 2
Dario asked on 23 Jan 2012, 02:50 PM
Hi to all,
I'have a cicle of several sections after every section (after I add current section), I call InsertPageBreak method in this mode:
MyRTBDocument.CaretPosition.MoveToLastPositionInDocument();
MyRTBDocument.InsertPageBreak();

I recevied "System.StackOverflowException" of document.

Before all I wrote this:
MyRTB.Document = new RadDocument();
MyRTB.Document.Sections.Add(new Telerik.Windows.Documents.Model.Section() { PageMargin = new Telerik.Windows.Documents.Layout.Padding(10, 10, 10, 10) });
MyRTB.Document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
MyRTB.Document.Arrange(new RectangleF(PointF.Empty, DocumentoCreato.Document.DesiredSize));

Why I receive this error?

3 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 25 Jan 2012, 01:08 PM
Hello Dario,

Thank you for getting to us about the issues you are experiencing.

First of all, RadDocument does not support multiple sections at this point. If you create and add several sections to the document, they will be merged when the document is measured and arranged (which happens when you show the document in a RadRichTextBox in the visual tree or when you invoke them explicitly).
We have multiple sections in our to-do list for 2012 Q1 and if everything goes according to plan, they will be included in the release in less than a month.

When it comes to setting the section's page margin, you can do that in one of the following ways:
1. Set SectionDefaultPageMargin of the document. This approach should be used when you are not creating the content of the document in code-behind and are not adding the section manually.

2. Set the PageMargin property of the section. If the document has not been measured before, the snippet in your post should work correctly. However, in case the document has been measured, you would either use the PageMargin of the first section in the document:
MyRTB.Document.Sections.First.PageMargin = new Telerik.Windows.Documents.Layout.Padding(10, 10, 10, 10) });

or create a new document in the following way:
RadDocument newDocument = new RadDocument();
newDocument.Sections.Add(new Telerik.Windows.Documents.Model.Section() { PageMargin = new Telerik.Windows.Documents.Layout.Padding(10, 10, 10, 10) });
newDocument.MeasureAndArrangeInDefaultSize();
//insert the PageBreak
 
MyRTB.Document = newDocument;

As for the SystemOverflowException, we did not manage to reproduce it, but it may be due to the fact that you are passing another document's DesiredSize in the Arrange method:
MyRTB.Document.Arrange(new RectangleF(PointF.Empty, DocumentoCreato.Document.DesiredSize));

I hope this helps.

Kind regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Dustin
Top achievements
Rank 1
answered on 27 Feb 2012, 04:08 PM
Was multiple section support added to the Q1 2012 release?
0
Iva Toteva
Telerik team
answered on 01 Mar 2012, 10:12 AM
Hi Dustin,

Multiple sections are supported starting from the last official release - 2012 Q1. New sections can be added to the document both programmatically and by inserting a section break from the UI (see attached screenshot).

You can have sections in the document with different page orientation, margins or headers and footers. The import and export has been implemented for docx, RTF, XAML, plain text and PDF (export only). As in HTML the properties that can vary between sections (margins, headers, etc.) are not exported, all sections will be exported as one and the import will create only one section.

I hope this helps.

Regards,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
Dario
Top achievements
Rank 2
Answers by
Iva Toteva
Telerik team
Dustin
Top achievements
Rank 1
Share this question
or