XamlFixed - Cannot create a "ImageSource" exception when parsing resulting xaml

Hi
I’m trying to export to xamlfixed from docx file that has a few images. When I use a xamlreader to either parse or load the resulting fixed document file I get an exception that the reader can’t create any of the imagesources.
I’m wondering how I get around this as I don’t see any save options that seem related and I also don’t have direct access to any of the images referenced as they’re embedded inside the docx package.
Any ideas or pointers would be most welcome.

Cheers

Hi
Thanks for your request. You can use XamlReader.Parse method and specify base uri where XamlReader should look for resources. I created a simple example for you:

<Window x:="" Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="448" Width="666" >
	<Grid>
		<DocumentViewer Name="docViewer" Margin="0,22,0,0" Grid.ColumnSpan="2"></DocumentViewer>
		<Button Height="23" HorizontalAlignment="Left" Name="btnLoadDoc" VerticalAlignment="Top" Width="113" Click="btnLoadDoc_Click">Load Document</Button>
	</Grid>
</Window>
using System;
using System.IO;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Markup;
using Aspose.Words;
namespace WpfApplication1
{
    ///
    /// Interaction logic for Window1.xaml
    ///
    public partial class Window1: Window
    {
        public Window1()
        {
            InitializeComponent();
        }
        private void btnLoadDoc_Click(object sender, RoutedEventArgs e)
        {
            // This is folder where we will save our XAML files produced by Aspose.Words.
            const string basePath = @"C:\Temp\";
            // Open document using Aspose.Words.
            Document doc = new Document(@"C:\Temp\in.docx");
            // Save document as fixed XAML.
            string outputFileName = Path.Combine(basePath, "out.xaml");
            doc.Save(outputFileName, SaveFormat.XamlFixed);
            // Now read XAML string from the created XAML file.
            string xamlString = File.ReadAllText(outputFileName);
            // Create parser contex and specify base url.
            // This is important because XamlReader will use base usrl to serach for resources.
            ParserContext context = new ParserContext();
            context.BaseUri = new Uri(basePath);
            // Parse XAML string.
            FixedDocument fixedDoc = (FixedDocument) XamlReader.Parse(xamlString, context);
            // Display the document in DocumentViewer
            docViewer.Document = fixedDoc;
        }
    }
}

Hope this helps.
Best regards,