條碼工具 二維碼庫(開發者指南) Curtis Chau 更新:2025年6月22日 下載 IronBarcode NuGet 下載 DLL 下載 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 二維碼是一種二維條碼,比傳統條碼更小巧、更容易使用。 它常用於幫助人們隨時隨地尋找資訊或與他們喜愛的品牌聯繫。 二維碼由兩部分組成-左半部和右半部。 二維碼的左半部通常為黑色像素,右半部為白色。掃描二維碼時,需要使用手機或電腦上的專用二維碼掃描器。此掃描器利用雷射技術高速掃描二維碼白色部分中的圖案,取得編碼數據,類似信用卡終端使用的掃描器。 二維碼可用於多種用途,例如展示商店資訊、廣告、促銷、優惠券和新聞文章。 你可能會在書的封面正面看到印有二維碼,但更常見的是在書的封底,或者二維碼可能被印在公告板上。 例如,可以在學校圖書館放置二維碼技術,用於存取書籍。 二維碼不僅可以幫助學生了解圖書館的內容,還可以提供指向各種附加資訊的鏈接,例如學生的線上測驗。 QR Code 技術有多種使用案例,包括行銷和廣告活動,電子商務網站,銷售點系統,非接觸式支付等。 雖然這些技術已經存在很久了,但直到最近,消費者才開始在日常生活中使用這些技術。 二維碼在廣告商和消費者中越來越受歡迎。 它們提供了一種便捷的方式,無需輸入地址或電話號碼即可快速獲取有關商品或服務的資訊。 如果你是製作二維碼圖像的程式設計師,請閱讀本指南,了解製作二維碼圖像有多麼簡單。 本文將介紹如何使用 JavaScript、Python 和 C# 等不同語言以程式方式掃描和建立二維碼。 我們開始吧。 QuaggaJS:JavaScript 函式庫 QuaggaJS 是一個用來產生條碼的 JavaScript 函式庫。 它利用現代瀏覽器功能,使其可在任何平台和瀏覽器上運行。 由於 QuaggaJS 具有效能快速、可移植性和相容性強等優點,因此被開發者廣泛使用。 這個 JavaScript 函式庫支援多種編碼類型,例如 UPC-A、UPC-E、Code 128、Code 39、Interleaved 2 of 5 (ITF) 和 EAN 8/13。使用它無需下載或安裝任何額外的依賴項。 QuaggaJS 讓開發人員只需幾行程式碼即可在 Web 上輕鬆產生複雜的條碼狀輸出。 它提供了一個高級 API,抽象化了底層 HTML5 canvas 和 JavaScript API 的所有複雜性,同時提供了合理的預設值。 QuaggaJS 已被眾多開發者和設計師廣泛用於創建將二維碼融入其設計中的數位行銷解決方案。 該函式庫也相容於 React Native、Angular、Vue.js、Ionic 4 等多種框架。 可以使用 NPM 指令安裝 QuaggaJS 函式庫。 以下是專案中使用 QuaggaJS 函式庫的程式碼範例: // Initialize the QuaggaJS library for processing barcodes Quagga.init({ inputStream: { name: "Live", // Stream type type: "LiveStream", // Live stream from a webcam target: document.querySelector('#yourElement') // Target HTML element for rendering }, decoder: { readers: ["code_128_reader"] // Barcode types to decode } }, function(err) { if (err) { console.log(err); // Log any initialization errors return; } console.log("Initialization finished. Ready to start"); Quagga.start(); // Start processing after initialization }); // Initialize the QuaggaJS library for processing barcodes Quagga.init({ inputStream: { name: "Live", // Stream type type: "LiveStream", // Live stream from a webcam target: document.querySelector('#yourElement') // Target HTML element for rendering }, decoder: { readers: ["code_128_reader"] // Barcode types to decode } }, function(err) { if (err) { console.log(err); // Log any initialization errors return; } console.log("Initialization finished. Ready to start"); Quagga.start(); // Start processing after initialization }); JAVASCRIPT 您可以使用靜態影像、即時網路攝影機或檔案 API 掃描條碼。 標誌:Python 庫 Segno 是一個用於在 Python 中讀取、寫入和產生條碼的函式庫。 有了這個庫,你可以輕鬆地從零開始創建條碼圖像。 Segno 使用 NumPy 陣列有效率地對條碼進行編碼和解碼。 Segno 的語法與 Python 的 turtle 模組之一類似,因此應該很容易快速掌握。 Segno 的設計理念是簡單易用,以便開發人員無需事先了解條碼生成知識即可使用它。 不過,它還擁有強大的 API,方便開發者擴展 Segno 的功能,以便更好地利用條碼。 Segno 的獨特功能包括根據條碼資料欄位以多種方式產生相同的條碼影像; 支援固定尺寸、可變尺寸或兩者兼有; 支援高分辨率柵格輸出; 側邊欄帶有工具提示,可以幫助使用者產生圖像。 以下是可在 Python 專案中使用的 Segno 程式庫的程式碼範例: # Import the Segno library import segno # Create a QR code with specified data qrcode = segno.make('Yellow Submarine') # Save the generated QR code as a PNG file qrcode.save('yellow-submarine.png') # Import the Segno library import segno # Create a QR code with specified data qrcode = segno.make('Yellow Submarine') # Save the generated QR code as a PNG file qrcode.save('yellow-submarine.png') PYTHON 您可以使用 PIP 安裝程式進行安裝。 IronBarcode:C# 條碼庫 IronBarcode 是一組支援條碼標準函式庫的程式碼物件。 這包括條碼編碼器、條碼產生器和編輯器等。 它提供了一個易於使用的 API,適用於行動和 Web 應用程式。 IronBarcode 透過提供一個標準化的程式碼物件庫來減少手動編碼工作量,這些程式碼物件可以在整個應用程式中重複使用。 這些物件透過自動化特定流程來縮短開發時間,並維護您的應用程序,使其更易於訪問,因為它們是跨平台標準化的。 IronBarcode 是目前成長最快的程式庫之一,因為它易於使用且效能卓越。 IronBarcode 無需任何更改或修改即可在 iOS、Android 和 Web 瀏覽器上運行,是您下一個專案的絕佳選擇。 該函式庫為條碼產生提供了一個抽象層,同時提供了一組標準實用程式和程式碼片段,以簡化開發。 導入此庫並傳遞生成的程式碼有助於建立條碼。 讓我們來看一些程式碼範例來了解庫的運行過程。 程式碼範例 using IronBarCode; //******* WRITE A QR CODE *******/ // Create a Barcode in 1 Line of Code BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode).SaveAsJpeg("QuickStart.jpg"); //******* READ A QR CODE *******/ // Read a Barcode in 1 Line of Code. Gets text, numeric codes, binary data, and an image of the barcode BarcodeResult result = BarcodeReader.QuicklyReadOneBarcode("QuickStart.jpg"); // Check the result of reading the QR code if (result != null && result.Text == "https://ironsoftware.com/csharp/barcode") { System.Console.WriteLine("Success!"); // Confirm the text matches } using IronBarCode; //******* WRITE A QR CODE *******/ // Create a Barcode in 1 Line of Code BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode).SaveAsJpeg("QuickStart.jpg"); //******* READ A QR CODE *******/ // Read a Barcode in 1 Line of Code. Gets text, numeric codes, binary data, and an image of the barcode BarcodeResult result = BarcodeReader.QuicklyReadOneBarcode("QuickStart.jpg"); // Check the result of reading the QR code if (result != null && result.Text == "https://ironsoftware.com/csharp/barcode") { System.Console.WriteLine("Success!"); // Confirm the text matches } Imports IronBarCode '******* WRITE A QR CODE *******/ ' Create a Barcode in 1 Line of Code BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode).SaveAsJpeg("QuickStart.jpg") '******* READ A QR CODE *******/ ' Read a Barcode in 1 Line of Code. Gets text, numeric codes, binary data, and an image of the barcode Dim result As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("QuickStart.jpg") ' Check the result of reading the QR code If result IsNot Nothing AndAlso result.Text = "https://ironsoftware.com/csharp/barcode" Then System.Console.WriteLine("Success!") ' Confirm the text matches End If $vbLabelText $csharpLabel 以上程式碼用於使用 IronBarcode 庫建立和讀取二維碼。 它使用起來很簡單。 您只需導入庫,編寫幾行程式碼,您的條碼即可使用和讀取。 using IronBarCode; /*** EXPORTING BARCODES AS HTML FILES OR TAGS ***/ // Create a barcode object GeneratedBarcode myBarCode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128); // Save as a stand-alone HTML file with no image assets required myBarCode.SaveAsHtmlFile("MyBarCode.html"); // Save as a stand-alone HTML image tag which can be served in HTML files, ASPX, or MVC Views. No image assets required, the tag embeds the entire image in its src contents string imgTag = myBarCode.ToHtmlTag(); // Turn the image into an HTML/CSS Data URI string dataURI = myBarCode.ToDataUrl(); using IronBarCode; /*** EXPORTING BARCODES AS HTML FILES OR TAGS ***/ // Create a barcode object GeneratedBarcode myBarCode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128); // Save as a stand-alone HTML file with no image assets required myBarCode.SaveAsHtmlFile("MyBarCode.html"); // Save as a stand-alone HTML image tag which can be served in HTML files, ASPX, or MVC Views. No image assets required, the tag embeds the entire image in its src contents string imgTag = myBarCode.ToHtmlTag(); // Turn the image into an HTML/CSS Data URI string dataURI = myBarCode.ToDataUrl(); Imports IronBarCode '''* EXPORTING BARCODES AS HTML FILES OR TAGS ** ' Create a barcode object Private myBarCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128) ' Save as a stand-alone HTML file with no image assets required myBarCode.SaveAsHtmlFile("MyBarCode.html") ' Save as a stand-alone HTML image tag which can be served in HTML files, ASPX, or MVC Views. No image assets required, the tag embeds the entire image in its src contents Dim imgTag As String = myBarCode.ToHtmlTag() ' Turn the image into an HTML/CSS Data URI Dim dataURI As String = myBarCode.ToDataUrl() $vbLabelText $csharpLabel IronBarcode 支援將二維碼匯出為 HTML 檔案或標籤。 它可以導出為表格標籤。 以上程式碼示範如何將二維碼轉換為 HTML。 您可以點擊此連結造訪 IronBarcode 庫網站,以了解更多詳情。 授權 IronBarcode 在開發階段是免費的。 您可以獲得商業用途或生產等級的免費試用版。 IronBarcode 依據開發者的需求提供三種定價方案。 您可以選擇最符合您需求的方案。 您也可以用購買 2 款 Iron Software 產品的價格購買 5 款 Iron Software 產品。 點擊此連結了解更多。 Curtis Chau 立即與工程團隊聊天 技術撰稿人 Curtis Chau 擁有電腦科學學士學位(卡爾頓大學),專長於前端開發,精通 Node.js、TypeScript、JavaScript 和 React。Curtis 對製作直覺且美觀的使用者介面充滿熱情,他喜歡使用現代化的架構,並製作結構良好且視覺上吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 也有濃厚的興趣,他喜歡探索整合硬體與軟體的創新方式。在空閒時間,他喜歡玩遊戲和建立 Discord bots,將他對技術的熱愛與創意結合。 相關文章 更新2025年10月29日 使用 IronBarcode 輕鬆產生符合 GS1 標準的條碼 學習如何使用 IronBarcode 以程式方式產生 GS1 條碼。按照我們的逐步指南,建立、自訂和驗證 GS1-128 和 DataMatrix 條碼,實現無縫的供應鏈管理。 閱讀更多 更新2025年10月29日 逐步指南:如何使用 QR Code Chimp 產生器 了解如何使用 QR Code Chimp Generator 產生動態二維碼。按照我們的逐步指南操作,探索各種自訂選項,實現高效的數位行銷。 閱讀更多 更新2025年7月28日 適用於安卓開發者的最佳條碼掃描器應用 在本文中,我們將探討一些適用於 Android 的最佳條碼掃描器應用程序,重點介紹它們的主要功能以及它們如何簡化日常任務。 閱讀更多 二維碼提取器(範例工具)來自 Image Online Tools 的二維...
更新2025年10月29日 使用 IronBarcode 輕鬆產生符合 GS1 標準的條碼 學習如何使用 IronBarcode 以程式方式產生 GS1 條碼。按照我們的逐步指南,建立、自訂和驗證 GS1-128 和 DataMatrix 條碼,實現無縫的供應鏈管理。 閱讀更多
更新2025年10月29日 逐步指南:如何使用 QR Code Chimp 產生器 了解如何使用 QR Code Chimp Generator 產生動態二維碼。按照我們的逐步指南操作,探索各種自訂選項,實現高效的數位行銷。 閱讀更多