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

RadFlowDocument Landscape Orientation

1 Answer 690 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Bertha
Top achievements
Rank 1
Bertha asked on 24 Sep 2018, 03:34 PM

I want to create the RadFlowDocument in Landscape.  I used the Section.  But I don't know how to use Section to insert text and insert line.  Is there  a easy way to change the whole document to Landscape mode?

Currently, I only find a full example of using editor.InsertText and editor.InsertLine.  So, I am using the same method.  Adding section could only change the margin, not the page orientation for whole document.

Section section = new Section(doc);
doc.Sections.Add(section);
section.PageMargins = new Telerik.Windows.Documents.Primitives.Padding(40, 40, 40, 40);
section.PageOrientation = PageOrientation.Landscape;
section.Rotate(PageOrientation.Landscape);

editor.InsertLine...

Thanks.

 

 

 

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 27 Sep 2018, 12:55 PM
Hello Bertha,

The PageOrientation property of the Section element determines the actual size of the paper to use when printing and doesn't reflect visualization. In order to affect the Section's appearance you should change the PageSize property, for example:
section.PageMargins = new Telerik.Windows.Documents.Primitives.Padding(40, 40, 40, 40);
section.PageOrientation = PageOrientation.Landscape;

Size size  = PaperTypeConverter.ToSize(PaperTypes.A4);
section.PageSize = new Size(size.Height, size.Width);

As another approach you can use the Rotate method, which internally changes the PageOrientationPageSize and PageMargin properties. However, if the Section's current orientation is identical with the orientation to be rotated to, no changes would be applied. The reason behind this is that if the PageOrientation property is already set changing the size and margins of the Section can lead to undesired visualization. For example, to rotate the Section element to Landscape orientation, you should apply the appropriate Portrait settings before invoking the Rotate method:
section.PageMargins = new Telerik.Windows.Documents.Primitives.Padding(40, 40, 40, 40);
section.PageSize = PaperTypeConverter.ToSize(PaperTypes.A4);
section.PageOrientation = PageOrientation.Portrait;
 
section.Rotate(PageOrientation.Landscape);


We understand that the current API is somewhat confusing, so we have logged a feature request in our feedback portal to provide more convenient API for creating Section instances for the desired page orientation: Introduce more convenient API for setting a Section's page orientation, where you can vote to increase the priority and subscribe to be notified for any status updates.

In order to add text content into a Section, you can add a Paragraph element and insert a Run content element:
section.Blocks.AddParagraph().Inlines.AddRun("Text");

I hope this helps.

Regards,
Georgi
Progress Telerik

Tags
WordsProcessing
Asked by
Bertha
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or