翻譯|使用教程|編輯:胡濤|2023-05-26 10:33:26.723|閱讀 122 次
概述:本指南將向您展示如何通過 Spire.Doc for .NET 創(chuàng)建條碼的方法。
# 界面/圖表報表/文檔/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等格式文件處理,小巧便捷。
E-iceblue 功能類庫Spire 系列文檔處理組件均由中國本土團隊研發(fā),不依賴第三方軟件,不受其他國家的技術(shù)或法律法規(guī)限制,同時適配國產(chǎn)操作系統(tǒng)如中科方德、中標麒麟等,兼容國產(chǎn)文檔處理軟件 WPS(如 .wps/.et/.dps 等格式
條碼是由若干個空白和黑色條紋按一定順序排列而成。表示一種商品的簡要信息,包括生產(chǎn)廠家、商品名稱、類別、價格等。目前,條碼在商品流通中應用廣泛。此外,人們可以在 Word 中創(chuàng)建條形碼并打印。
是一個獨立的專業(yè).NET Word 組件,使用戶可以使用C#、VB.NET 在Word 中創(chuàng)建條形碼。因此,本指南將向您展示如何通過 Spire.Doc for .NET 創(chuàng)建的方法。
首先,您需要在您的系統(tǒng)上安裝條形碼字體。然后,通過調(diào)用p.AppendText(string)方法添加條碼文本,然后為其設(shè)置文本格式屬性,如FontName、FontSize、TextColor等。運行后,我們可以得到如下截圖的結(jié)果。
下載并安裝 Spire.Doc for .NET,然后使用以下代碼在 Word 中創(chuàng)建條形碼。
[C#]
using System.Drawing; using Spire.Doc; using Spire.Doc.Documents; using Spire.Doc.Fields; namespace WordBarcode { class BarCode { static void Main(string[] args) { //Create Document Document document = new Document(); Paragraph p = document.AddSection().AddParagraph(); //Add Barcode and Set Format TextRange txtRang = p.AppendText("H63TWX11072"); txtRang.CharacterFormat.FontName = "C39HrP60DlTt"; txtRang.CharacterFormat.FontSize = 80; txtRang.CharacterFormat.TextColor = Color.SeaGreen; //Save and Launch document.SaveToFile("barcode.docx", FileFormat.Docx); System.Diagnostics.Process.Start("barcode.docx"); } } }
[VB.NET]
Imports System.Drawing Imports Spire.Doc Imports Spire.Doc.Documents Imports Spire.Doc.Fields Namespace WordBarcode Friend Class BarCode Shared Sub Main(ByVal args() As String) 'Create Document Dim document As New Document() Dim p As Paragraph = document.AddSection().AddParagraph() 'Add Barcode and Set Format Dim txtRang As TextRange = p.AppendText("H63TWX11072") txtRang.CharacterFormat.FontName = "C39HrP60DlTt" txtRang.CharacterFormat.FontSize = 80 txtRang.CharacterFormat.TextColor = Color.SeaGreen 'Save and Launch document.SaveToFile("barcode.docx", FileFormat.Docx) System.Diagnostics.Process.Start("barcode.docx") End Sub End Class End Namespace
Spire.Doc 是一個 Microsoft Word 組件,它使用戶能夠直接執(zhí)行范圍廣泛的 Word 文檔處理任務,例如在 WPF、.NET 和 Silverlight 中生成、讀取、寫入和修改 Word 文檔。
以上便是如何通過 Spire.Doc for .NET 創(chuàng)建條碼,如果您有其他問題也可以繼續(xù)瀏覽本系列文章,獲取相關(guān)教程,你還可以給我留言或者加入我們的官方技術(shù)交流群。
歡迎下載|體驗更多E-iceblue產(chǎn)品
獲取更多信息請咨詢 ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn