Here is my code that is in a class extending DocumentPaginator
public override DocumentPage GetPage(int pageNumber)
{
BitmapImage source = new BitmapImage();
using (Stream stream = new FileStream(GetPagePath(pageNumber), FileMode.Open))
{
source.BeginInit();
source.StreamSource = stream;
source.CacheOption = BitmapCacheOption.OnLoad;
source.EndInit();
}
var image = new Image { Source = source };
Rect contentBox = new Rect(PageSize);
return new DocumentPage(image, PageSize, contentBox, contentBox);
}
However when I actually run this code, it doesn't seem to load my image and merely prints blank pages.
What is the correct way to load my image and attach it to a DocumentPage
object?