作者:乔山办公网日期:
返回目录:word文档
在Word中我们可以对插入到文档中的图片的大小进行调整,使得图片与文章更加协调、美观。本文将介绍如何使用Spire.Doc和C#来调整Word文档中图片的大小。
以下是我们所使用的示例文档的截图:
代码段:
//加载Word文档Document document = new Document("Input.docx");//获取第一个sectionSection section = document.Sections[0];//获取第一个段落Paragraph paragraph = section.Paragraphs[0];//调整段落中图片的大小 foreach (DocumentObject docObj in paragraph.ChildObjects){ if (docObj is DocPicture) { DocPicture picture = docObj as DocPicture; picture.Width = 50f; picture.Height = 50f; }}//保存文档 document.SaveToFile("ResizeImages.docx");
效果图:
点击“了解更多”下载产品最新试用版
↓↓↓