翻譯|使用教程|編輯:顏馨|2023-05-09 10:46:15.280|閱讀 109 次
概述:
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Spire.Doc for .NET是一款專門對 Word 文檔進(jìn)行操作的 .NET 類庫。在于幫助開發(fā)人員無需安裝 Microsoft Word情況下,輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔。擁有近10年專業(yè)開發(fā)經(jīng)驗Spire系列辦公文檔開發(fā)工具,專注于創(chuàng)建、編輯、轉(zhuǎn)換和打印Word/PDF/Excel等格式文件處理,小巧便捷。
E-iceblue 功能類庫Spire 系列文檔處理組件均由中國本土團(tuán)隊研發(fā),不依賴第三方軟件,不受其他國家的技術(shù)或法律法規(guī)限制,同時適配國產(chǎn)操作系統(tǒng)如中科方德、中標(biāo)麒麟等,兼容國產(chǎn)文檔處理軟件 WPS(如 .wps/.et/.dps 等格式
在我們的教程中,有文章介紹了插入、刪除、定位文本框和從文本框中提取文本的方法。本文將提供有關(guān)如何使用 Spire.Doc 包含的位置和線型設(shè)置設(shè)置文本框的內(nèi)部邊距的文檔。
注意:在開始之前,請下載最新版本的 Spire.Doc,并在 bin 文件夾中添加.dll作為 Visual Studio 的參考。
步驟1:創(chuàng)建Word文檔并添加一個部分。
Document document = new Document(); Section sec = document.AddSection();
步驟2:添加文本框并附加示例文本。
TextBox TB = document.Sections[0].AddParagraph().AppendTextBox(310, 90); Paragraph para = TB.Body.AddParagraph(); TextRange TR = para.AppendText("Using Spire.Doc, developers will find a simple and effective method to endow their applications with rich MS Word features. "); TR.CharacterFormat.FontName = "Cambria "; TR.CharacterFormat.FontSize = 13;
步驟3:設(shè)置文本框的確切位置。
TB.Format.HorizontalOrigin = HorizontalOrigin.Page; TB.Format.HorizontalPosition = 80; TB.Format.VerticalOrigin = VerticalOrigin.Page; TB.Format.VerticalPosition = 100;
步驟4:設(shè)置文本框的線條樣式。
TB.Format.LineStyle = TextBoxLineStyle.Double; TB.Format.LineColor = Color.CornflowerBlue; TB.Format.LineDashing = LineDashing.DashDotDot; TB.Format.LineWidth = 5;
步驟5:為文本框設(shè)置內(nèi)部邊距:
TB.Format.InternalMargin.Top = 15; TB.Format.InternalMargin.Bottom = 10; TB.Format.InternalMargin.Left = 12; TB.Format.InternalMargin.Right = 10;
步驟6:保存文檔并啟動以查看效果。
document.SaveToFile("result.docx",FileFormat.docx2013); System.Diagnostics.Process.Start("result.docx");
效果:
完整代碼:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Spire.Doc; using Spire.Doc.Documents; using Spire.Doc.Fields; using System.Drawing; namespace Demo { class Program { static void Main(string[] args) { Document document = new Document(); Section sec = document.AddSection(); TextBox TB = document.Sections[0].AddParagraph().AppendTextBox(310, 90); Paragraph para = TB.Body.AddParagraph(); TextRange TR = para.AppendText("Using Spire.Doc, developers will find a simple and effective method to endow their applications with rich MS Word features. "); TR.CharacterFormat.FontName = "Cambria "; TR.CharacterFormat.FontSize = 13; TB.Format.HorizontalOrigin = HorizontalOrigin.Page; TB.Format.HorizontalPosition = 80; TB.Format.VerticalOrigin = VerticalOrigin.Page; TB.Format.VerticalPosition = 100; TB.Format.LineStyle = TextBoxLineStyle.Double; TB.Format.LineColor = Color.CornflowerBlue; TB.Format.LineDashing = LineDashing.DashDotDot; TB.Format.LineWidth = 5; TB.Format.InternalMargin.Top = 15; TB.Format.InternalMargin.Bottom = 10; TB.Format.InternalMargin.Left = 12; TB.Format.InternalMargin.Right = 10; document.SaveToFile("result.docx",FileFormat.docx2013); System.Diagnostics.Process.Start("result.docx"); } } }
以上便是通過Spire.Doc將Doc轉(zhuǎn)換為PDF時如何使用卸載的字體的教程,如果您有其他問題也可以繼續(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