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

Set document margins when converting html to word

2 Answers 629 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 23 Aug 2016, 04:40 AM

I need help setting document margins when convert html to word using the following technique.

string html = "<p>hello world!</p>";
HtmlFormatProvider provider = new HtmlFormatProvider();
RadFlowDocument document = provider.Import(html);

I tried using the following with no luck

PageMargins = new Telerik.Windows.Documents.Primitives.Padding(30, 0, 0, 5);

Are there any examples showing what I require?

Thank you

Andy

2 Answers, 1 is accepted

Sort by
0
Accepted
Tanya
Telerik team
answered on 24 Aug 2016, 11:07 AM
Hello Andrew,

The margins of a page could be controlled through the properties of the Section element. There is more detailed information on how to set the in our documentation.

After importing the document, you can access each of its elements using the EnumerateChildrenOfType() method. The following snippet demonstrates how to obtain the first Section in RadFlowDocument instance:
Section firstSection = document.EnumerateChildrenOfType<Section>().First();

Hope this is helpful.

Regards,
Tanya
Telerik by Progress

0
Andrew
Top achievements
Rank 1
answered on 25 Aug 2016, 01:56 AM
Than you. That worked.
Tags
WordsProcessing
Asked by
Andrew
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or