none
Saving FlowDocument into file RRS feed

  • Question

  • I am using FlowDocumentReader...
    I wish to save the text in the reader into a file, either in .txt, docx, or doc..
    it is easier to save the file in .xps but may I know any other easy ways to save the text into these formats...

    thanks.
    Tuesday, April 15, 2008 5:29 AM

Answers

  • The framework can enable you to save the FlowDocument into text or xaml format, docx or doc format is not supported, here is an example:
    FlowDocument doc = new FlowDocument();
    using (FileStream fs = new FileStream(@"c:\demo.xaml", FileMode.OpenOrCreate, FileAccess.Write))
    {
        TextRange textRange = new TextRange(doc.ContentStart, doc.ContentEnd);
        textRange.Save(fs, DataFormats.Xaml);
    }

    Hope this helps
    Thursday, April 17, 2008 2:48 AM

All replies

  • The framework can enable you to save the FlowDocument into text or xaml format, docx or doc format is not supported, here is an example:
    FlowDocument doc = new FlowDocument();
    using (FileStream fs = new FileStream(@"c:\demo.xaml", FileMode.OpenOrCreate, FileAccess.Write))
    {
        TextRange textRange = new TextRange(doc.ContentStart, doc.ContentEnd);
        textRange.Save(fs, DataFormats.Xaml);
    }

    Hope this helps
    Thursday, April 17, 2008 2:48 AM
  • I am able to save the content from flowdocument into docx file.

    But can i add a header to the docx file? I need to display the title from the flowdocument to the docx header.

    please advice.


    Change
    Thursday, August 19, 2010 9:23 AM