Page 1 of 1

How to use FlowDucument-property

Posted: Mon Apr 26, 2010 5:29 am
by stehwn
Hi,

my businessobject has text-properties of type FlowDocument (can be converted to rtf).
Is it possible to use the formatted FlowDocument for report-creation?


Best Regards

How to use FlowDucument-property

Posted: Mon Apr 26, 2010 2:08 pm
by Jan
Hello,

We have added new static method which can help you load FlowDocument to richtext. New method will be available in prerelease build from 26 April. Please use following code for GetValueEvent of richtext component:

Code: Select all

System.IO.Stream stream = new System.IO.FileStream("d:\\test.xaml", System.IO.FileMode.Open);
string str = Stimulsoft.Report.Wpf.StiRtfHelper.ConvertFlowDocumentToRtf(stream);
e.Value = System.Xml.XmlConvert.EncodeName(StiRichText.PackRtf(str));
You need add reference to Stimulsoft.Report.Wpf.dll in ReferencedAssemblies property of report. You can do this in report designer. Also you can implement method ConvertFlowDocumentToRtf in report code. Here is source code of this method:

Code: Select all

public static string ConvertFlowDocumentToRtf(Stream stream)
        {
            RichTextBox richTextBox = new RichTextBox();

            TextRange documentTextRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
            documentTextRange.Load(stream, DataFormats.Xaml);

            MemoryStream tempStream = new MemoryStream();
            documentTextRange.Save(tempStream, DataFormats.Rtf);
            return System.Text.Encoding.Default.GetString(tempStream.GetBuffer());

        }
Thank you.

How to use FlowDucument-property

Posted: Tue Apr 27, 2010 2:26 am
by stehwn
Thank you!

I'll try that.

Best Regards

How to use FlowDucument-property

Posted: Tue Apr 27, 2010 3:04 am
by Andrew
Hello,

Let us know about the result.

Thank you.

How to use FlowDucument-property

Posted: Wed Apr 28, 2010 11:00 am
by stehwn
Hi,

I tested it and it works without any problems!

I let my businessobject do the converting, so I dont have to add references in the designer.


Best Regards
Steffen

How to use FlowDucument-property

Posted: Thu Apr 29, 2010 2:09 pm
by Jan
Hello Steffen,

Glad to help you.

Thank you.