翻譯|使用教程|編輯:胡濤|2022-10-19 13:11:36.697|閱讀 131 次
概述: 本文主要介紹了如何借助C#/VB.NET在 Word 中插入藝術(shù)字,歡迎查閱~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Spire.Doc for .NET是一款專門對 Word 文檔進行操作的 .NET 類庫。在于幫助開發(fā)人員無需安裝 Microsoft Word情況下,輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔。擁有近10年專業(yè)開發(fā)經(jīng)驗Spire系列辦公文檔開發(fā)工具,專注于創(chuàng)建、編輯、轉(zhuǎn)換和打印Word/PDF/Excel等格式文件處理,小巧便捷。在 C#、VB.NET 中從 Word 中提取圖像。
藝術(shù)字是 MS Word 中的一項功能,可讓您在文檔中插入色彩豐富且時尚的文本。除此之外,它還可以彎曲、拉伸或傾斜文本的形狀,這是一種通過特殊效果使文本脫穎而出的快速方法。在本文中,您將學(xué)習(xí)如何使用Spire.Doc for .NET以編程方式將藝術(shù)字插入 Word 文檔。
首先,您需要添加 Spire.Doc for .NET 包中包含的 DLL 文件作為 .NET 項目中的引用。DLL 文件可以從此鏈接下載或通過NuGet安裝。
PM> Install-Package Spire.Doc
Spire.Doc 為 .NET 提供的ShapeType枚舉定義了各種名稱以“Text”開頭的藝術(shù)字形狀類型。為了在 Word 中創(chuàng)建藝術(shù)字,您需要初始化一個ShapeObject實例并指定藝術(shù)字類型和文本內(nèi)容。詳細步驟如下:
【C#】
using Spire.Doc; using Spire.Doc.Documents; using Spire.Doc.Fields; namespace CreatWordArt { class Program { static void Main(string[] args) { //Create a Document instance Document doc = new Document(); //Add a section Section section = doc.AddSection(); //Add a paragraph Paragraph paragraph = section.AddParagraph(); //Append a shape to the paragraph and specify the shape size and type ShapeObject shape = paragraph.AppendShape(400, 150, ShapeType.TextDeflateBottom); //Set the position of the shape shape.VerticalPosition = 60; shape.HorizontalPosition = 60; //Set the text of WordArt shape.WordArt.Text = "Create WordArt in Word"; //Set the fill color and stroke color of WordArt shape.FillColor = System.Drawing.Color.Cyan; shape.StrokeColor = System.Drawing.Color.DarkBlue; //Save the document doc.SaveToFile("CreateWordArt.docx", FileFormat.Docx2013); } } }
【VB.NET】
Imports Spire.Doc Imports Spire.Doc.Documents Imports Spire.Doc.Fields Namespace CreatWordArt Class Program Private Shared Sub Main(ByVal args As String()) 'Create a Document instance Dim doc As Document = New Document() 'Add a section Dim section As Section = doc.AddSection() 'Add a paragraph Dim paragraph As Paragraph = section.AddParagraph() 'Append a shape to the paragraph and specify the shape size and type Dim shape As ShapeObject = paragraph.AppendShape(400, 150, ShapeType.TextDeflateBottom) 'Set the position of the shape shape.VerticalPosition = 60 shape.HorizontalPosition = 60 'Set the text of WordArt shape.WordArt.Text = "Create WordArt in Word" 'Set the fill color and stroke color of WordArt shape.FillColor = System.Drawing.Color.Cyan shape.StrokeColor = System.Drawing.Color.DarkBlue 'Save the document doc.SaveToFile("CreateWordArt.docx", FileFormat.Docx2013) End Sub End Class End Namespace
以上便是如何使用 C# 在 Word 中替換圖像,如果您有其他問題也可以繼續(xù)瀏覽本系列文章,獲取相關(guān)教程,你還可以給我留言或者加入我們的官方技術(shù)交流群。
歡迎下載|體驗更多E-iceblue產(chǎn)品
獲取更多信息請咨詢 ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn