Spire.Presentation 8.11.1 已发布。本次更新新增支持多项功能,如获取形状中文本区域的高度和宽度以及获取形状中多行的文本。此外,本次更新还修复了执行 shape.TextFrame.GetTextLocation() 方法时程序抛出 System.InvalidCastException 异常的问题。详情请阅读以下内容。
新功能:
- 支持转换形状到SVG时保持形状相对幻灯片的位置信息。
- 支持获取形状中的文本区域的高度和宽度。
- 支持获取形状中多行的文本。
- 支持获取OleObject对象的ShapeID属性。
byte[] svgByte = shape.SaveAsSvgInSlide();
FileStream fs = new FileStream("shapePath_" + num + ".svg", FileMode.Create);
fs.Write(svgByte, 0, svgByte.Length);
fs.Close();
IAutoShape autoShape = shape as IAutoShape;
SizeF size = autoShape.TextFrame.GetTextSize();
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
ISlide slide = ppt.Slides[0];
for (int i = 0; i < slide.Shapes.Count; i++)
{
IAutoShape shape = (IAutoShape)slide.Shapes[i];
File.AppendAllText(outputFile, "shape" + i + ":" + "\r\n");
IList <LineText> lines = shape.TextFrame.GetLayoutLines();
for (int j = 0; j < lines.Count; j++)
{
File.AppendAllText(outputFile,"line[" + j + "]:" + lines[j].Text + "\r\n");
}
}
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
OleObjectCollection oles = ppt.Slides[0].OleObjects;
OleObject oleObject = oles[0];
StringBuilder sb = new StringBuilder();
sb.AppendLine("ShapeID="+oleObject.ShapeID);
foreach(DictionaryEntry entry in oleObject.Properties)
{
sb.AppendLine(entry.Key+":" +entry.Value);
}
File.AppendAllText(outputFile, sb.ToString());
问题修复:
- 修复了执行shape.TextFrame.GetTextLocation()方法时程序抛出System.InvalidCastException异常的问题。
获取Spire.Presentationt 8.11.1请点击: