我正在尝试将 a 的页面PdfDocument
作为一组BitmapImage
's 保存到磁盘中,为此我使用了 WinRTXamlToolkit 提供的扩展名。
PdfPage page = pdfd.GetPage(0); // pdfd is a loaded PdfDocument
InMemoryRandomAccessStream str=new InMemoryRandomAccessStream();
await page.RenderToStreamAsync(str);
BitmapImage bmp = new BitmapImage();
await bmp.SetSourceAsync(str);
WriteableBitmap wb = await WriteableBitmapFromBitmapImageExtension.FromBitmapImage(bmp);
StorageFolder sfo;
sfo = await KnownFolders.DocumentsLibrary.CreateFolderAsync("PDFasBMP", CreationCollisionOption.OpenIfExists);
await WriteableBitmapSaveExtensions.SaveToFile(wb,sfo,"Yahooo.bmp");
输出“Yahooo.bmp”是一个不可读的 58 字节文件。我错过了什么?该问题与 WinRTXamlToolkit 无关,因为当它BitmapImage
被设置为 Web 中的图像时,它会正确保存到磁盘中,所以问题在于 PdfPage 的工作方式。