これがクラス拡張にある私のコードです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);
}
ただし、実際にこのコードを実行すると、画像が読み込まれず、空白のページが印刷されるだけです。
DocumentPage
画像を読み込んでオブジェクトに添付する正しい方法は何ですか?