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 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