在 IIS 服务下使用 COM 在 C# 中将 PowerPoint 渲染为 png 时出现问题
首先,我的程序可以将 pptx 渲染为 png,但在 Windows Server 2008 R2 上渲染时质量大大降低,我想知道为什么。
我使用 Cassini 在 Windows 7 x64 上测试了我的程序,并且将 pptx 渲染为 png 是完美的。但是,当我在 IIS 上部署程序并尝试渲染 pptx 时,其渲染质量会降低。
这是同一张图像的链接,一张在 Windows 7 cassini 下渲染,另一张在 Windows Server 2008 下渲染。
完美质量的一张:http://dl.dropbox.com/u/2458800/exemple-high-quality.png
低质量的:http://dl.dropbox.com/u/2458800/exemple-low-quality .png
这似乎是某种抗锯齿问题。
最后,这是我的代码:
var powerPoint = new Application();
var presentation = powerPoint.Presentations.Open(sourceFile,
MsoTriState.msoFalse, MsoTriState.msoTriStateMixed, MsoTriState.msoFalse);
presentation.Export(destinationDir, "png", 960, 720);
presentation.Close();
powerPoint.Quit();
编辑:
我知道使用 PowerPoint COM 在服务器上会出现问题。尝试了Aspose,问题解决了。
first of all, my program CAN render a pptx to png, the quality is just greatly reduced when rendering on Windows Server 2008 R2 and I'm wondering why.
I tested my program on windows 7 x64 using Cassini and the rendering to png of the pptx is perfect. But when I deploy my program on IIS and try to render the pptx, the quality of its rendering is reduced.
This is the link the same image, one rendered under windows 7 cassini and the other under windows server 2008.
The perfect quality one: http://dl.dropbox.com/u/2458800/exemple-high-quality.png
The low quality one: http://dl.dropbox.com/u/2458800/exemple-low-quality.png
It appears to be some sort of an antialiasing problem.
Finally, here is my code:
var powerPoint = new Application();
var presentation = powerPoint.Presentations.Open(sourceFile,
MsoTriState.msoFalse, MsoTriState.msoTriStateMixed, MsoTriState.msoFalse);
presentation.Export(destinationDir, "png", 960, 720);
presentation.Close();
powerPoint.Quit();
EDIT:
Well I knew that going with PowerPoint COM would be a problem on a server. Tried Aspose and that solved the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MS 不支持在服务中使用 PPT 自动化(IIS 是一项服务)...请参阅 http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
使用不带自动化功能的第 3 方解决方案(例如Aspose)...不附属..
using PPT automation in a service (IIS is a service) is NOT supported by MS... see http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
Use a 3rd-party solution without automation (for example Aspose)... not affiliated..
例如,使用 SysInternals 的 ZoomIt 实用程序来查看差异。服务器呈现的文本未消除锯齿。
微软严厉警告称,Office程序被设计为在工作站上运行,不适合在服务器环境中使用。这是副作用之一。您必须要求服务器管理员将服务器的视频适配器设置为 32 bpp 模式并启用抗锯齿功能。我希望它有一个。请访问 serverfault.com 询问更多相关信息
Use, say, SysInternals' ZoomIt utility to see the difference. The text that was rendered by the server is not anti-aliased.
Microsoft sternly warns that Office programs were designed to run on a work station and are not suitable for use in a server environment. This is one of the side-effects. You'll have to ask the server administrator to put the server's video adapter in a 32 bpp mode with anti-aliasing enabled. I hope it has one. Ask more about this at serverfault.com