I have a FlowDocument with Background image. Currently it does not display properly in FlowDocumentReader since the background image stays centered when document is scrolled up and down. How to convert this FlowDocument to FixedDocument and display it in DocumentViewer, so the background image will be fixed as well ?
I use the conversion logic from here. But it does not display the FlowDocument.Background image.
private FixedDocument convert(FlowDocument flowDocument)
{
if (flowDocument == null)
return null;
var paginator = ((IDocumentPaginatorSource)flowDocument).DocumentPaginator;
var package = Package.Open(new MemoryStream(), FileMode.Create, FileAccess.ReadWrite);
var packUri = new Uri("pack://temp.xps");
PackageStore.RemovePackage(packUri);
PackageStore.AddPackage(packUri, package);
var xps = new XpsDocument(package, CompressionOption.NotCompressed, packUri.ToString());
XpsDocument.CreateXpsDocumentWriter(xps).Write(paginator);
FixedDocument doc = xps.GetFixedDocumentSequence().References[0].GetDocument(true);
return doc;
}