Note that there are some explanatory texts on larger screens.

plurals
  1. POSerializing WPF FlowDocuments to/from PackagePart (including images, etc.)
    primarykey
    data
    text
    <p>I want to be able to store multiple FlowDocuments within a single package, including images, etc. within each document. However, none of the methods I've seen for saving (and loading) Xaml FlowDocuments seem capable of this.</p> <ul> <li>TextRange.Save with DataFormats.Xaml strips images and other embedded content</li> <li>TextRange.Save with DataFormats.XamlPackage creates a whole new package, rather than allowing me to treat the document and included images as parts within the package I'd be storing it in</li> <li>XamlWriter looks like it could be good for this, but I can't figure out how to find all the embedded objects for putting in their own parts (although I certainly know how to handle them once I've found them). On the other end, I haven't a clue how to make everything load properly later on.</li> </ul> <p>It's pretty annoying that there's no one-stop way of serializing a FlowDocument and its images, etc. to a PackagePart. If anyone's figured out a good way of doing this, how'd you pull it off?</p> <p><strong>UPDATE 2011-07-03 00:22:</strong> Using XamlWriter and some extra code from <a href="https://stackoverflow.com/questions/3899852/finding-all-images-in-a-flowdocument" title="Finding all Images in a FlowDocument">this question</a> I've been able to build a happy little OPC-compliant package which can hold multiple FlowDocuments including their images, as PackageParts. However, going the other way (from PackagePart to FlowDocument) is failing, because no matter how I try to load the document, I get XamlParseExceptions telling me that</p> <blockquote> <p>'Initialization of 'System.Windows.Media.Imaging.BitmapImage' threw an exception.'</p> </blockquote> <p>So, the question now becomes, how do I manhandle XamlReader.Load and/or my part's stream in order to get the related images loaded properly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload