如题
比如 有个word文件 有3页, 第三页右下方 有个 shape
我应该如何才能获取到
shape 所在页数: 3 (或者2可以,如果开始是0的话)
shape width、height、left、top。等等真实的值呢?
谢谢。
Document document = new Document();
document.LoadFromFile("fileName");
//遍历章节
for (int i = 0; i < document.Sections.Count; i++)
{
Section section = document.Sections[i];
//遍历段落
for (int j = 0; j < section.Paragraphs.Count; j++)
{
Paragraph p = section.Paragraphs[j];
//遍历子元素
for (int k = 0; k < p.ChildObjects.Count; k++)
{
DocumentObject obj = p.ChildObjects[k];
//判断子元素是否为shape
if (obj.DocumentObjectType == DocumentObjectType.Shape)
{
ShapeObject shape1 = obj as ShapeObject;
float x = shape1.HorizontalPosition;
float y = shape1.VerticalPosition;
double Width = shape1.Width;
double height=shape1.Height;
Console.WriteLine("shape所在章节:" + (i+1)+" 宽度为:"+Width+" 高度为:"+height+" top为:"+x+" left为:"+y);
Console.ReadLine();
}
}
}
}