IRONSOFTWAREHOME
在 HTML 轉 PDF 中新增條碼
using IronPdf;
using IronPdf.Editing;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.RenderDelay(500);

// Load barcode via HTML
var barcodeHtml = @"<link href=""https://fonts.googleapis.com/css?family=Libre%20Barcode%20128""rel = ""stylesheet"" ><p style = ""font-family: 'Libre Barcode 128', serif; font-size:30px;""> Hello Google Fonts</p>";
var doc = renderer.RenderHtmlAsPdf(barcodeHtml);

// or use the BarcodeStamper
var barcodeStamp = new BarcodeStamper("Hello World", BarcodeEncoding.Code39);
doc.ApplyStamp(barcodeStamp);

// Export to a file or Stream
doc.SaveAs("bc-test.pdf");
Imports IronPdf
Imports IronPdf.Editing

' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
renderer.RenderingOptions.WaitFor.RenderDelay(500)

' Load barcode via HTML
Dim barcodeHtml = "<link href=""https://fonts.googleapis.com/css?family=Libre%20Barcode%20128""rel = ""stylesheet"" ><p style = ""font-family: 'Libre Barcode 128', serif; font-size:30px;""> Hello Google Fonts</p>"
Dim doc = renderer.RenderHtmlAsPdf(barcodeHtml)

' or use the BarcodeStamper
Dim barcodeStamp = New BarcodeStamper("Hello World", BarcodeEncoding.Code39)
doc.ApplyStamp(barcodeStamp)

' Export to a file or Stream
doc.SaveAs("bc-test.pdf")
NuGet Download
PM > Install-Package IronPdf
在 HTML 轉 PDF 中新增條碼

在 HTML 轉 PDF 中新增條碼

除了支援各種自訂字型如Google字型外,IronPDF也支援將條碼加蓋於您的PDF文件上。 這使得開發者能夠輕鬆地在呈現的PDF中包含條碼資訊。

使用IronPDF生成帶有條碼的PDF步驟

首先,確保IronPdf程式庫已安裝並已匯入您的專案中。 然後,初始化ChromePdfRenderer類別的實例,讓您能將HTML內容渲染成高品質的PDF文件。

接下來,您需要建立您的條碼內容。 以我們的案例如例,我們建立了一個HTML字串,其中包含了一個Google Fonts連結,使用"Libre Barcode 128"字型。 接著,使用RenderHtmlAsPdf方法將HTML內容轉換成新的PDF文件。

在HTML渲染後,建立一個包含"Hello World"文字的條碼印章,搭配Code39編碼格式。 此印章然後運用ApplyStamp方法塗抹到PDF文件上。

最後,生成的PDF使用SaveAs方法儲存為名為"bc-test.pdf"的檔案。 這個簡單的過程使您能有效地在您的C#應用程式中生產包含樣式文字和條碼內容的PDF。 須注意有些情況下,這項功能不支援某些條碼型別,例如QR碼。 在這些情況下,一個有效的解決方案是使用IronBarcode生成此條碼或QR碼,然後將其作為圖像新增到您的PDF中。

學習如何使用IronPDF在PDF中新增圖片
在GitHub上查看

準備開始了嗎?

Nuget Downloads 21,105,021版本:2026.9剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰。

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

OR
bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
預訂您的免費現場演示
Booking Badge

受到全球數百萬工程師的信任

Iron Software的客戶標誌
獲取您的無義務諮詢
填寫以下表格或電子郵件sales@ironsoftware.com
您的詳細資訊將始終保密。
受到全球數百萬工程師的信任
Iron Software的客戶標誌
立即獲取您的30天試用金鑰。
無需信用卡或帳戶建立
C# 用於PDF的NuGet程式庫
使用NuGet安裝

版本: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. 在解決方案資源管理器,右鍵點選參考,管理NuGet包
  2. 選擇瀏覽並搜尋"IronPdf"
  3. 選擇套件並安裝
C# PDF DLL
下載DLL

版本: 2026.9

或者點擊此處下載Windows安裝程式。

  1. 下載並解壓IronPDF到類似~/Libs的位置,位於您的解決方案目錄中
  2. 在Visual Studio解決方案資源管理器,右鍵點選參考。選擇瀏覽,"IronPdf.dll"

授權從$999起