【发布时间】:2015-10-08 05:18:52
【问题描述】:
这是我在扩展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 对象的正确方法是什么?
【问题讨论】:
-
我看过那个帖子...
FixedPage与DocumentPage不同。 -
您是否尝试过该答案中的代码来创建
BitmapImage实例? -
是的。它对输出没有影响。
-
GetPagePath方法有什么作用?
标签: c# wpf image documentpaginator