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

HtmlFormatProvider - headers and footers?

3 Answers 67 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 24 Feb 2012, 02:14 PM
It seems that HtmlFormatProvider doesn't export headers or footers - I realise this is probably intentional, as HTML isn't normally associated with a more fixed-document type layout.

However, it would be preferable in the situation I'm working on for the HTML to more closely represent a fixed document layout - e.g. fixed width divs, page breaks - and this should include the headers and footers.

Is this something that would be considered?  I suppose I could write my own FormatProvider implementation!

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 29 Feb 2012, 12:42 PM
Hello Charles,

You are right, headers and footers are not persisted in HTML. At this point we are not considering the implementation of header/footer and sections export in HTML. Furthermore, considering the differences between our document model and HTML, there will be quite a few setbacks when building a more fixed-layout export and import.
The best format to preserve the document is XAML, but you can alse create a custom format provider. For example, you can export parts of the document using HtmlFormatProvider and other parts using your own custom logic. This could be achieved by implementing ITextBasedDocumentFormatProvider interface - a sample implementation can be found in our structured content editing demo for Silverlight: http://demos.telerik.com/silverlight/?windowless=true#RichTextBox/StructuredContentEditing. The approach with WPF would be the same.

I hope this helps.

Greetings,
Martin
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Charles
Top achievements
Rank 1
answered on 14 Mar 2012, 06:29 PM
Hi Martin

I'm not particularly bothered about using Html to persist the document and retrieve - I'm only trying to generate an output file for human consumption.  Hopefully this will make things a little simpler!

I can easily get the headers and footers (as far as I can tell, they're just separate RadDocument instances).  What I can't quite work out yet is how I might go about finding where each page's content start and ends.  Before I spend ages trawling the source to see how RadRichTextBox paginates, any pointers?(!)

Thanks

Charlie
0
Iva Toteva
Telerik team
answered on 19 Mar 2012, 08:28 PM
Hello Charlie,

RadRichTextBox does not keep any pointers as to where one page ends and another one starts, as it calculates the layout of the document on the fly.
You can use DocumentPositions before exporting the document and use their methods:

position.MoveToFirstPositionOnNextPage();
position.MoveToLastPositionOnPreviousPage();
position.MoveToNext();
position.MoveToPrevious();

You can get the associated inline (Span, ImageInline,  document element at a document position like this:
Inline inline = position.GetCurrentInlineBox().AssociatedInline;

From the inline, you can get its Parent (Paragraph) and traverse the tree of the document as far up as necessary. You can look through the following articles to get the basic idea about document elements and positions:
Elements Hierarchy
Positioning and DocumentPosition API
Search through DocumentPositions
Regards,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
Charles
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Charles
Top achievements
Rank 1
Iva Toteva
Telerik team
Share this question
or