Problem rendering a PowerPoint to png in C# using

2020-05-06 08:27发布

问题:

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.

回答1:

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..



回答2:

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