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

Set Document Width to A4

5 Answers 832 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 04 May 2012, 03:18 AM
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

5 Answers, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 04 May 2012, 01:07 PM
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 >>

0
Joao
Top achievements
Rank 1
answered on 02 Aug 2012, 04:48 PM
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
0
Joao
Top achievements
Rank 1
answered on 02 Aug 2012, 06:35 PM
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.
0
Harri
Top achievements
Rank 1
answered on 23 Oct 2012, 09:06 AM
 '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?
0
Petya
Telerik team
answered on 23 Oct 2012, 05:21 PM
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.

Tags
RichTextBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Joao
Top achievements
Rank 1
Harri
Top achievements
Rank 1
Petya
Telerik team
Share this question
or