Set Document Width to A4

6 posts, 1 answers
  1. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 03 May 2012 Link to this post

    Hi,

    Is there a way to set a document width to A4? or any standard paper width for that matter (A1, A2, A3, A4... etc).

    Thanks,

    Rob
  2. Answer
    Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 04 May 2012 Link to this post

    Hi Rob,

    The size of the initial document can be set in XAML like this:

    <telerik:RadRichTextBox Name="radRichTextBox" Grid.Row="1" Margin="24 24 0 0" LayoutMode="Paged">
        <telerik:RadDocument SectionDefaultPageSize="793,1123" />
    </telerik:RadRichTextBox>

    Note that if you change the document (or execute the NewDocumentCommand), the new document will not use these settings.

    You can also use the PaperTypeConverter and the values in the enum PaperTypes in order to change dynamically the size of the page:
    this.radRichTextBox.ChangeSectionPageSize(PaperTypeConverter.ToSize(PaperTypes.A4));

    I hope this answers your question.

    Regards,
    Iva Toteva
    the Telerik team

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

  3. UI for WPF is Visual Studio 2017 Ready
  4. Joao
    Joao avatar
    7 posts
    Member since:
    Oct 2012

    Posted 02 Aug 2012 Link to this post

    Hi Iva,

    I have got a similar request to Robert:

    # How can I programmatically create a RadDocument and set its Section Size to 'A4', or 'A3', or other types of paper?

    Looking at the RadDocument members I found a deprecated property called 'DefaultPageLayoutSettings'. The underlying type is 'PageLayoutSettings' which has a constructor using the enum 'PaperTypes'. This enum seems very handy: I only need to know which type of paper (easy to show a list in the UI for the end user to choose from) and the RadDocument (via DefaultPageLayoutSettings) will set internally the 'width' and 'height' of the page according to the type of paper chosen,

    Looks like the new recommended member, aka 'PageLayoutSettings', does not have a constructor based on the enum 'PaperTypes'.

    # Does it mean I have to measure the various piece of paper and store that information somewhere in my code to use it for setting 'PageLayoutSettings'?

    Thank you in advance,
    Joao
  5. Joao
    Joao avatar
    7 posts
    Member since:
    Oct 2012

    Posted 02 Aug 2012 Link to this post

    Hi,

    Looks like I found what I was after: 'PaperTypeConverter' (namespace 'Telerik.Windows.Documents.Model').

    It has a single static method:
    public static Size ToSize(PaperTypes type);

    Thanks.
  6. Harri
    Harri avatar
    12 posts
    Member since:
    Oct 2012

    Posted 23 Oct 2012 Link to this post

     'Telerik.Windows.Controls.RadRichTextBox' does not contain a definition for 'ChangeSectionPageSize' and no extension method 'ChangeSectionPageSize' accepting a first argument of type 'Telerik.Windows.Controls.RadRichTextBox' could be found (are you missing a using directive or an assembly reference?) 

    Just me?
  7. Petya
    Admin
    Petya avatar
    975 posts

    Posted 23 Oct 2012 Link to this post

    Hello Harri,

    There is a ChangeSectionPageSize method of Telerik.Windows.Controls.RadRichTextBox. The signature of this method is as follows:

    public void ChangeSectionPageSize(Size newSize)

     This means that it should be used as Iva pointed out earlier:
    this.radRichTextBox.ChangeSectionPageSize(PaperTypeConverter.ToSize(PaperTypes.A4));

    Make sure that you have referenced all assemblies listed here.

    You should also have in mind that if you change the document instance in the RadRichTextBox, its PageSize will return to the default one. 

     
    Kind regards,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready