今天就跟大家聊聊有關(guān)怎么在C#中利用Aspose.Words 刪除word中的圖片,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

string tempFile = Application.StartupPath + "\\resource\\templete\\項(xiàng)目建議書模板.doc";
Document doc = new Document(tempFile);
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape item in shapes)
{
if (item.HasImage)
{
item.Remove();
}
}
doc.Save(docPath);補(bǔ)充:C#word插入圖片在指定標(biāo)簽位置(附加圖片上下左右移動(dòng))
這一篇我就直接講講圖片的添加和移動(dòng)了

如上圖是直接插入,插入位置是鑲嵌類型,我想讓它浮動(dòng)在文字下面,且大小也想調(diào)動(dòng)一下
object Nothing = System.Reflection.Missing.Value;
try
{
//定義該插入圖片是否為外部鏈接
object linkToFile = false;
//定義插入圖片是否隨word文檔一起保存
object saveWithDocument = true;
//圖片
string replacePic = picture;
if (doc.Bookmarks.Exists(bookMark_text) == true)
{
object bookMark = bookMark_text;
//查找書簽
doc.Bookmarks.get_Item(ref bookMark).Select();
//設(shè)置圖片位置
worldApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
//在書簽的位置添加圖片
InlineShape inlineShape = worldApp.Selection.InlineShapes.AddPicture(replacePic, ref linkToFile, ref saveWithDocument, ref Nothing);
//設(shè)置圖片大小
inlineShape.Width = 100;
inlineShape.Height = 100;
inlineShape.Select();
inlineShape.ConvertToShape().IncrementLeft(-60.0f);
//將圖片設(shè)置浮動(dòng)在文字上方
inlineShape.ConvertToShape().WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;
}
}
catch
{
doc.Saved = false;
//word文檔中不存在該書簽,關(guān)閉文檔
doc.Close(ref Nothing, ref Nothing, ref Nothing);
}其中inlineShape.ConvertToShape()可以理解為選中這個(gè)圖片
IncrementLeft();方法是要素水平移動(dòng),正值 代表向右移動(dòng),負(fù)值代表向左移動(dòng)
IncrementTop();方法是要素垂直移動(dòng),正值代表向下移動(dòng),負(fù)值代表向上移動(dòng)
看完上述內(nèi)容,你們對怎么在C#中利用Aspose.Words 刪除word中的圖片有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。
網(wǎng)頁標(biāo)題:怎么在C#中利用Aspose.Words刪除word中的圖片-創(chuàng)新互聯(lián)
當(dāng)前URL:http://www.chinadenli.net/article20/deedco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、網(wǎng)站收錄、App開發(fā)、軟件開發(fā)、服務(wù)器托管、動(dòng)態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容