创建一个powerpoint文件阅读器(pptx) [英] Creating a power-point file reader ( pptx )

查看:70
本文介绍了创建一个powerpoint文件阅读器(pptx)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个开源 pptx 阅读器(在 C# 中首选)来修改它并将其放入 3D 引擎(客户要求),或者至少是基础教程.我已经在谷歌上搜索过,但找不到任何有用的资源.

我知道通过阅读 pptx 文件文档 (ECMA) 可以创建一个新的阅读器,但这似乎是一个庞大的项目,如果我能够在一些现有代码上构建这个组件,我更愿意.

解决方案

你的选择

使用的最佳选项实际上取决于您需要进行的修改.如果您希望能够大量操作 PowerPoint 演示文稿、绘制新形状、旋转形状、添加图表、添加幻灯片或母版幻灯片等,您可能会发现像 Aspose.Slides 库(专有)这样的抽象层非常有用.

如果您不想为库付费,可以在 .NET 中使用 OpenXML 格式.它们允许您操作 PPTX 文档的每个方面,而无需 Interop/COM,因为它们解析 PPTX 内的 XML.

从个人经验来看,使用了这两种方法后,Aspose 是一种简单得多的解决方案,但它提供了一些开销,当然也有成本.OpenXML 路线易于使用,但需要一些学习曲线.

最后但并非最不重要的一点,你可以看看 NetOffice,它实现了类似于 Aspose 的东西,它是轻一点,功能也减少了.它还涵盖其他格式,不需要在机器上安装 Office.

总结您的选择:

我的建议

如果您需要进行一些简单的修改(例如提取幻灯片、更改某处的一些文本、替换图像),我会选择 OpenXML.

如果您想以定制的方式绘制幻灯片,我会选择 Aspose.我已经在 50.000 LoC 应用程序中使用 Aspose 使用 WCF 构建了数十万个 PowerPoint 幻灯片(有时多达 100 张幻灯片).Aspose 一直在绘制每张幻灯片并生成所有形状.生成一副牌大约需要 4-5 秒.Aspose 的加载和 Aspose 的小问题可能会令人恼火(一个人可以在大约 200 毫秒内处理一张幻灯片).此外,Aspose 演示文稿不可序列化,如果您想以某种形式缓存结果,这很烦人.

如果您想阅读 PPTX 并以某种方式将其转换为图像,Aspose.Slides 是一个不错的选择,因为它允许您将 PPTX 幻灯片转换为随后可以处理的 SVG.请注意,有一些 PPTX2SVG 引擎 (XSLT),但我知道的引擎是用 Java (Apache) 编写的.

注意事项

我提到的库都是针对 .NET/C# 环境的库.这些库和技术都不需要安装 office/interop/com.

I'm looking for an open-source pptx reader (preferred in C# ) to modify it and put it into a 3D engine ( customer request ), or at least a tutorial on the basics. I already searched on google but can't find any useful resources.

I know it's possible to create a new reader by reading the pptx files documentation ( ECMA ), but this seems to be a huge project anyway and I would prefer if I'm able to build this component on some existing code.

解决方案

Your options

The best option to use really depends on the modifications you need to do. If you want to be able to heavily manipulate the PowerPoint presentation, draw new shapes, rotate shapes, add charts, add slides or master slides etc. you may find an abstraction layer like the Aspose.Slides library (proprietary) very useful.

If you do not want to pay for the library, the OpenXML formats are available to you in .NET. They allow you to manipulate every aspect of the PPTX document without the need for Interop/COM as they parse the XML inside the PPTX.

From personal experience, having used both, Aspose is a far easier solution but one that provides some overhead and of course has a cost. The OpenXML route is light to use, but requires some learning curve.

Last but not least, you can take a look at NetOffice which achieves something similar to Aspose, it is a little lighter and has reduced functionality. It also covers other formats and does not require Office installs on the machine.

To sum your options:

My advice

If you need to do some simple modifications (e.g. extract a slide, change a bit of text somewhere, replace an image) I would go with OpenXML.

If you want to draw slides in a bespoke manner, I would go with Aspose. I have used Aspose in a 50.000 LoC application to build hundreds of thousands of PowerPoint decks (up to a 100 slides at times) using WCF. Aspose has been drawing each slide and generating all the shapes. It takes about 4-5 seconds for a deck to be generated. The loading of Aspose and small issues with Aspose can be irritating (one can process a slide in around 200ms). Also Aspose presentations are not serializable, which is annoying if you want to cache the results in some form.

If you want to read the PPTX and somehow convert it to images, Aspose.Slides is a good candidate because it allows you to convert a PPTX slide to SVG which you can subsequently process. Note that there are some PPTX2SVG engines out there (XSLT) but the ones I know are written in Java (Apache).

Notes

The libraries I mentioned are all libraries for the .NET/C# environment. None of these libraries and techniques require office/interop/com installs.

这篇关于创建一个powerpoint文件阅读器(pptx)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆