【发布时间】:2014-02-07 17:22:12
【问题描述】:
在过去的几个月里,我一直在开发一个使用 Windows 8.1 PDF API 的应用程序。它在各种设备上运行良好,包括:
- 我的开发 PC 运行 8.1 Pro
- 一台运行 Windows 8.1 Pro 的笔记本电脑(不支持触控)
- 运行 Windows 8.1 Pro 的虚拟机
- 运行 Windows 8.1 Enterprise 的虚拟机
- 运行 Windows Embedded 8.1 Industry Pro 的虚拟机
- 一台运行 Windows 8.1 Pro 的迷你电脑
- 运行 Windows 8.1 Home 的三星平板电脑
但是,我们最近购买了两台 Surface 2 RT 来运行这个应用程序,我们现在面临一个奇怪的问题。我已将问题缩小到 PDF API。在下面的 PNG 中,您会看到渲染中存在一些奇怪的行为,导致生成的图像中出现一些空白区域。当我保持接近“原始”大小时,它似乎可以正常工作(在 PdfPageRenderOptions 中没有指定任何内容的情况下我会得到的大小,考虑到它从一个设备更改为另一个设备,它并不是真正的“原始”)。但是,如果我尝试从 PDF 渲染更大的图像,结果就是这样。
渲染: http://postimg.org/gallery/226weuga/
表面 RT 设备
- DebugOriginal_Surface.png:未缩放时所需的行为。这是我在 Surface RT 设备上得到的。
- DebugZoom_Surface.png:缩放时的问题行为。这是我在 Surface RT 设备上得到的。
- AnotherZoomLevel_Surface.png:进一步缩放时的另一个问题行为。这就是我得到的。
任何其他设备
- DebugZoomed_DevMachine.png:缩放时所需的行为。这是我在任何 Windows 非 RT 设备上得到的。
- DebugOriginal_DevMachine.png:未缩放时所需的行为。这是我在任何 Windows 非 RT 设备上得到的。
我删除了我的代码,以确保它不是 UI 问题或我缓存 pdf 文件的方式等。我的代码现在非常简单,如下面的示例所示:
var pdfFile = await StorageFile.GetFileFromPathAsync(NavigationService.Drawing.Path);
_pdfDoc = await PdfDocument.LoadFromFileAsync(pdfFile);
if (_pdfDoc.PageCount > 0)
{
StorageFolder folder = ApplicationData.Current.TemporaryFolder;
StorageFile pngFileOriginal = await folder.CreateFileAsync("DebugOriginal_" + Guid.NewGuid().ToString() + ".png", CreationCollisionOption.ReplaceExisting);
StorageFile pngFileZoomed = await folder.CreateFileAsync("DebugZoomed_" + Guid.NewGuid().ToString() + ".png", CreationCollisionOption.ReplaceExisting);
using (IRandomAccessStream fileStream = await pngFileOriginal.OpenAsync(FileAccessMode.ReadWrite))
{
await _pdfDoc.GetPage(0).RenderToStreamAsync(fileStream);
await fileStream.FlushAsync();
}
using (IRandomAccessStream fileStream = await pngFileZoomed.OpenAsync(FileAccessMode.ReadWrite))
{
await _pdfDoc.GetPage(0).RenderToStreamAsync(fileStream, new PdfPageRenderOptions { DestinationWidth = 2000 });
await fileStream.FlushAsync();
}
}
这是 API 的问题还是我的问题?
编辑
Microsoft 的 PDF API 示例 (http://code.msdn.microsoft.com/windowsapps/PDF-viewer-sample-85a4bb30) 在 Surface 2 RT 设备上执行相同的操作。
编辑 2
该错误出现在 Surface 2 RT 上,但不在 Surface 1 RT 上。这显然是硬件问题。
【问题讨论】:
-
你的意思是包含图片的链接吗?
-
并不是说这有帮助,但乍一看似乎是显示驱动程序问题。
-
显示驱动程序可能会影响 PDF 呈现 API?此外,它是完全更新的全新 Surface 2。没有接触任何驱动程序,但微软不会确保将驱动程序作为 Windows 更新推送吗?如果没有,是否可以更新 RT 设备上的驱动程序?
-
当然,包括缩放在内的任何渲染都可能受到显示驱动程序故障的影响。它只发生在特定设备上的事实让我认为它与显示相关。我看不出你的代码是如何导致它的。
-
另外需要注意的是,它是我们试用该应用程序的唯一 ARM/RT 设备。
标签: c# .net pdf windows-runtime winrt-xaml