当前位置: 首页 > 网络应用技术

c#获取指定的图片坐标位置(带有vb.net)

时间:2023-03-06 11:05:15 网络应用技术

  以下内容介绍了通过C#和VB.NET代码示例在Word文档中指定的图片的坐标位置。

  如下:

  1.指定文件路径,此测试代码路径是项目文件夹路径。也就是说,在Visual Studio Project文件下进行测试的Word文档,例如:C:userAdministratorsVisualVisual Visio 2013ProjectStractextrackexdimage_docgetCoimgbindebindebug est.docx.定制为其他路径。

  2.在“解决方案资源管理器”中介绍必要的汇编文件,如下图所示:

  加载一词测试文档文档doc = new document();doc.loadfromfile(“ test.docx”);//穿越(int a = doc.sections.count-1; a> = 0; a-){pection protect = doc.Sections [a];//遍历(int j = ection.paragraphs.count-1; j> = 0; j-)的段落段{段段= e节if(picture.tital.equals(“图片4”)//定位标题“图片4”图片{//获取图片坐标位置float float x = picture.horizontalposital; float; float y = picturepicture。verticalPosition; console.Writeline(console.Writeline)(“坐标”位置是:

  x =“ + x +”

  y =“ + y); console.Readline();}}}}}}}}}}}}}}}

  4.完成代码后,执行程序,输出图像坐标获得结果,如下所示:

  )doc.loadfromfile(“ test.docx”)'a as aS aS aS aS integer = doc.sections.count -1至0 step -1 dim section as section = doc.Sections(a)'遍历段落段落.4“”的段落部分。图片''获取图片坐标位置dim x单= picture.horizontalposition dim y as single = picture.verticalPosition(“坐标位置为:”&vblf&“ x =” + x + x + x + vblf&“ y&” y = y =vblf&“ ylf&” ylf&“ ylf&” ylf&“ ylf&” ylf&“ ylf&” ylf&“ ylf&” ylf&“ ylf&” ylf&“ ylf&” ylf&“ ylf” + y)console.Readline()结束如果下一个下一个下一个next next ext终点空间