Can't change the PageLayoutSetting

4 posts, 0 answers
  1. Andrea Ferrari
    Andrea Ferrari avatar
    9 posts
    Member since:
    Apr 2010

    Posted 28 May 2010 Link to this post

    I need to show some formatted pages on a Book. My customer have seen the Book component and he says: "Wonderful", so now I've to do it.
    I've starder creating an Editor (of course my customer wanto to edit/modify the pages) using the RichTextBox wich load and save the pages on the customers database.
    One day is gone, but the result is fine.

    Now I've to create the Book on a page with dynamic width and hight, so I created a UserControl with a RichTextBox inside, without setting the Height and Width, but setting the Margin.

    And now???
    I've tryied to change the dimension of the page dynamically with the following method when the RichTextBox is loaded:

        private void editor_Loaded(object sender, RoutedEventArgs e)  
          RadRichTextBox tb = sender as RadRichTextBox;  
          tb.Document.PageLayoutSettings.Height = controlSize.Height - defaultMargin.Top - defaultMargin.Bottom;  
          tb.Document.PageLayoutSettings.Width = controlSize.Width - defaultMargin.Left - defaultMargin.Right; ;  
    But, I don't know how to change the left and top margin of the page. Where are the left, top, bottom and right property of the RichTextBox Page?

    Thanks a lot and Regards.
    Andrea Ferrari
  2. Mike
    Mike avatar
    640 posts

    Posted 31 May 2010 Link to this post

    Hello Andrea Ferrari,

    To change the default PageMargins of a document you can use the property RadDocument.SectionDefaultPageMargin. Note that when a document in stored in Xaml format it contains information about PageMargins. In this case, after loading document you may need to set the page margin of the first Section in the document:

    Kind regards,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Jeffrey
    Jeffrey avatar
    21 posts
    Member since:
    Mar 2014

    Posted 14 May 2018 in reply to Mike Link to this post

    Specifically how do you change it using RadDocument.SectionDefaultPageMargin as you suggest? If I wanted .5" margins all around what would that look like in code?
  4. Georgi
    Georgi avatar
    45 posts

    Posted 16 May 2018 Link to this post

    Hi Jeffrey,

    To set the SectionDefaultPageMargin property to 0.5 inches, you will need to first convert the value to pixels, as they are used as the measurement unit by the API. This could be easily achieved using the Unit class:
    double marginAll = 0.5;
    this.radRichTextBox.Document.SectionDefaultPageMargin = new Padding(Convert.ToInt32(Unit.InchToDip(marginAll)));

    If the changes should be applied to the document after it has been loaded in the editor, you can call the RadRichTextBox.ChangeSectionPageMargin() method:
    private void radRichTextBox_Loaded(object sender, RoutedEventArgs e)
        double marginAll = 0.5;
        this.radRichTextBox.ChangeSectionPageMargin(new Padding(Convert.ToInt32(Unit.InchToDip(marginAll))));

    I hope this helps.

    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top