Spire.Presentation 8.10.2已发布。该版本新增支持获取形状内文本的位置信息的功能。同时也支持获取形状中文本的“Ascent”和“Descent”属性和将形状转换为SVG格式。此外,还修复了将PPT转换为SVG后,用浏览器打开SVG文件时出现空白的问题。详情请阅读以下内容。
新功能:
- 支持获取形状内文本的位置信息。
- 支持获取形状中文本的“Ascent”和“Descent”属性。
- 支持将形状转换为SVG格式。
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
StringBuilder sb = new StringBuilder();
ISlide slide = ppt.Slides[0];
for (int i = 0; i < slide.Shapes.Count; i++)
{
IShape shape = slide.Shapes[i];
if (shape is IAutoShape)
{
IAutoShape autoshape = slide.Shapes[i] as IAutoShape;
string text = autoshape.TextFrame.Text;
//obtain the text position information
PointF point = autoshape.TextFrame.GetTextLocation();
sb.AppendLine("Shape " + i + ":" + text + "\r\n" + "location:" + point.ToString());
}
}
File.AppendAllText(outputFile, sb.ToString());
ppt.Dispose();
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
ISlide slide = ppt.Slides[0];
IAutoShape autoshape = slide.Shapes[0] as IAutoShape;
IList<LineText> lines = autoshape.TextFrame.GetLayoutLines();
for (int i = 0; i < lines.Count; i++)
{
float ascent= lines[i].Ascent;
float descent = lines[i].Descent;
}
Presentation ppt = new Presentation();
ppt.LoadFromFile("FreeForm.pptx");
ISlide slide = ppt.Slides[0];
int num = 0;
foreach (IShape shape in slide.Shapes)
{
byte[] svgByte = shape.SaveAsSvg();
FileStream fs = new FileStream("shape_" + num + ".svg",FileMode.Create);
fs.Write(svgByte, 0, svgByte.Length);
fs.Close();
num++;
}
问题修复:
- 修复了将PPT转换为SVG后,用浏览器打开SVG文件时出现空白的问题。
获取Spire.Presentationt 8.10.2请点击:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-NET.html