【问题标题】:Export PowerPoint shape with real size以真实大小导出 PowerPoint 形状
【发布时间】:2012-12-28 13:33:15
【问题描述】:

我需要将 PowerPoint 中选择的形状导出为具有真实形状大小的 png 图像。我使用此代码进行导出:

var args = new object[] { filePath, Microsoft.Office.Interop.PowerPoint.PpShapeFormat.ppShapeFormatPNG, 0, 0, Microsoft.Office.Interop.PowerPoint.PpExportMode.ppRelativeToSlide };
objectShape.GetType().InvokeMember("Export", System.Reflection.BindingFlags.InvokeMethod, null, objectShape, args); // Export to file on disk

在磁盘上,我的图像比例和高度/宽度不正确。我尝试了 PpExportMode 枚举参数的不同值,以防万一我将 PP 中的缩放更改为 100%。但我没有正确的结果。对于基于矩形的形状,它可以正常工作。但例如对于星形或标注形状,实际尺寸不等于形状的高度/宽度属性。这是因为形状底部的小舌头。

有人知道如何正确导出这些形状吗?

【问题讨论】:

  • 你在哪里找到这个时髦的方法:objectShape.GetType().InvokeMember("Export",documentation 表示使用 Shape.Export(PathName, Filter, ScaleWidth, ScaleHeight, ExportMode)
  • 我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。
  • Jeremy - 我的 Microsoft.Office.Interop.PowerPoint.Shape 没有导出方法。所以我找到了这篇文章link
  • 约翰 - 感谢您的指正。

标签: c# vsto powerpoint


【解决方案1】:

检查形状的 .Adjustments.Count 属性。

If Adjustments.Count > 0 Then
For x = 1 to Adjustments.Count
  '  Store the value of Adjustments(x) somewhere
  '  so you can reset it later
  .Adjustments(x) = 0
Next

现在导出形状,然后将其调整重置为之前的值。

或者只是复制形状,将其调整设置为 0,将其导出,然后将其删除。

【讨论】:

  • 史蒂夫,非常感谢您的回答。它给了我搜索的方向。我需要导出带有所有调整的形状,因此我的图像应该看起来与原始形状(所有调整)相同,并在 PP 中 100% 缩放。
猜你喜欢
  • 2013-10-02
  • 1970-01-01
  • 2015-07-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多