c# - 以实际大小导出 PowerPoint 形状

标签 c# vsto powerpoint

我需要将在 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%。但是我没有正确的结果。对于基于矩形的形状,它可以正常工作。但例如对于星形或标注形状,实际大小不等于形状的高度/宽度属性。这是由于形状底部的小舌头造成的。

enter image description here

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

最佳答案

检查形状的 .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,导出它,然后将其删除。

关于c# - 以实际大小导出 PowerPoint 形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14063556/

相关文章:

c# - 打印 Windbg 中所有数据表的所有表名

c# - Properties.Settings.Default.Save() 不保存

c# - 如何确定构建程序集的 MSBuild 版本?

c# - 通过功能区代码隐藏在 Word 中打开文件

ms-office - 不是有效的 Office 加载项

c# - 在 C# 中访问 PowerPoint 图表

Javascript 连接表格单元格 ASP.NET MVC

visual-studio-2008 - 无法调试 Excel 2003 插件 (XLL)

excel - 从 Powerpoint 关闭 Excel

python-pptx:如何重新定位图片占位符?