Call InsertPageBreak and then "System.StackOverflowException"

4 posts, 0 answers
  1. Dario
    Dario avatar
    61 posts
    Member since:
    Apr 2011

    Posted 23 Jan 2012 Link to this post

    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:

    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.Arrange(new RectangleF(PointF.Empty, DocumentoCreato.Document.DesiredSize));

    Why I receive this error?
  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 25 Jan 2012 Link to this post

    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) });
    //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 >>

  3. DevCraft R3 2016 release webinar banner
  4. Dustin
    Dustin avatar
    79 posts
    Member since:
    Oct 2012

    Posted 27 Feb 2012 Link to this post

    Was multiple section support added to the Q1 2012 release?
  5. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 01 Mar 2012 Link to this post

    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.

    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 >>
Back to Top