IronBarcode 操作指南 .NET 加蓋條碼 PDF How to Stamp Barcodes on PDFs Hairil Hasyimi Bin Omar 更新日期:7月 22, 2025 Download IronBarcode NuGet 下載 DLL 下載 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English 二級標題:快速開始:將已生成的條碼蓋章到PDF頁面上 這個單行示例顯示了您可以多麼輕鬆地使用IronBarCode的CreateBarcode生成條碼並立即將其蓋章到現有的PDF頁面上。 您只需提供PDF路徑、座標位置和頁碼,即可獲得一個可用於生產的工作流程,且設置要求最低。 Get started making PDFs with NuGet now: Install IronBarcode with NuGet Package Manager PM > Install-Package BarCode Copy and run this code snippet. IronBarCode.BarcodeWriter.CreateBarcode("https://my.site", IronBarCode.BarcodeEncoding.QRCode, 150, 150) .StampToExistingPdfPage("report.pdf", x: 50, y: 50, pageNumber: 1); Deploy to test on your live environment Start using IronBarcode in your project today with a free trial Free 30 day Trial class="hsg-featured-snippet"> 最低的工作流程(5步驟) 下載C#庫來在PDF上蓋章條碼 創建一個具有指定條碼類型和值的條碼 指定條碼的大小 利用StampToExistingPdfPage方法將條碼蓋章到單個PDF頁面上 使用StampToExistingPdfPages方法將條碼蓋章到多個PDF頁面上 在現有的PDF頁面上蓋章條碼 Apart from exporting barcodes as PDF, one of the most popular functionalities in IronBarcode is the ability to stamp the GeneratedBarcode directly onto a user's existing PDF document. 以下代碼片段演示了如何做到這一點。 :path=/static-assets/barcode/content-code-examples/how-to/StampBarcodeOnExistingPdfPage.cs using IronBarCode; GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Code128, 200, 100); myBarcode.StampToExistingPdfPage("pdf_file_path.pdf", x: 200, y: 100, 3, "password"); Imports IronBarCode Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Code128, 200, 100) myBarcode.StampToExistingPdfPage("pdf_file_path.pdf", x:= 200, y:= 100, 3, "password") $vbLabelText $csharpLabel 從上面的代碼片段中,我們只需使用帶有GeneratedBarcode對象的StampToExistingPdfPage()方法將對象蓋章到PDF文檔上。 以下是此方法中使用的參數: pdfFilePath:一個表示內存中PDF文檔路徑的System.String。 x:表示PDF頁面上的橫坐標位置的System.Int32,單位為像素。 y:表示PDF頁面上的縱坐標位置的System.Int32,單位為像素。 pageNumber:指示要蓋章的PDF頁面的System.Int32。注意,該值是從1開始計數的,因此第1頁表示為1。 password:用於打開PDF所需密碼的System.String。 這是可選的,僅用於密碼保護的PDF。 如果PDF未受密碼保護,用戶可以將此參數留空。 運行上述代碼片段將立即在PDF文檔中蓋章GeneratedBarcode,而不需要中間文檔的保存步驟。 在多個PDF頁面上蓋章條碼 有時需要在多個頁面上而不是僅一個頁面上蓋章相同的條碼。 與其反覆調用上述方法在多個頁面上蓋章相同的條碼,用戶可以直接使用GeneratedBarcode類中的StampToExistingPdfPages()方法來做到這一點。 以下代碼片段演示了如何使用此方法。 :path=/static-assets/barcode/content-code-examples/how-to/StampBarcodeOnMultiplePdfPages.cs using IronBarCode; using System.Collections.Generic; GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Code128, 200, 100); List<int> pages = new List<int>(); pages.Add(1); pages.Add(2); pages.Add(3); myBarcode.StampToExistingPdfPages("pdf_file_path.pdf", x: 200, y: 100, pages, "password"); Imports IronBarCode Imports System.Collections.Generic Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Code128, 200, 100) Private pages As New List(Of Integer)() pages.Add(1) pages.Add(2) pages.Add(3) myBarcode.StampToExistingPdfPages("pdf_file_path.pdf", x:= 200, y:= 100, pages, "password") $vbLabelText $csharpLabel 以下是此方法中使用的參數: pdfFilePath:一個表示內存中PDF文檔路徑的System.String。 x:表示PDF頁面上的橫坐標位置的System.Int32,單位為像素。 y:表示PDF頁面上的縱坐標位置的System.Int32,單位為像素。 pageNumbers:由IEnumerable<System.Int32>組成的PDF頁碼集。注意,這些值是從1開始計數的,因此PDF的第1頁表示為1。 password:用於打開PDF所需密碼的System.String。 這是可選的,僅用於密碼保護的PDF。 如果PDF未受密碼保護,用戶可以將此參數留空。 常見問題解答 如何在 C# 中在 PDF 文件上加蓋條碼? 您可以使用 IronBarcode 庫在 C# 中對 PDF 文件加蓋條碼。首先,從 NuGet 下載該庫,創建具有指定參數的條碼,然後使用 StampToExistingPdfPage 或 StampToExistingPdfPages 方法將條碼應用到 PDF 頁面。 我應該使用什麼方法來在單個 PDF 頁面上加蓋條碼? 要在單個 PDF 頁面上加蓋條碼,使用 IronBarcode 庫的 StampToExistingPdfPage 方法。此方法需要參數如 PDF 檔案路徑、位置的 x 和 y 坐標、頁碼以及受保護 PDF 的可選密碼。 如何在 PDF 的多個頁面上加蓋條碼? 要在多個 PDF 頁面上加蓋條碼,使用 StampToExistingPdfPages 方法。這允許您指定多個頁碼,並自動在這些頁面上加蓋條碼,而無需手動循環遍歷這些頁面。 我可以在受密碼保護的 PDF 上加蓋條碼嗎? 是的,您可以使用 IronBarcode 在受密碼保護的 PDF 上加蓋條碼。使用 StampToExistingPdfPage 或 StampToExistingPdfPages 方法時,需要將密碼作為可選參數提供。 加蓋條碼到 PDF 需要哪些參數? 所需參數包括用於文件路徑的 pdfFilePath、位置的 x 和 y、目標頁面的 pageNumber,以及訪問受保護 PDF 的可選 password。 我需要在使用 IronBarcode 加蓋條碼後保存 PDF 嗎? 是的,在加蓋條碼後,您應使用 SaveAs 方法保存修改過的 PDF 文件,以確保更改得到保留。 如何下載用於在 PDF 上加蓋條碼的庫? 用於在 PDF 上加蓋條碼的庫可以從 NuGet 套件管理器下載。在 nuget.org/packages/IronPdf 上搜索 IronPdf 包。 我可以使用 IronBarcode 創建哪種類型的條碼? IronBarcode 允許您創建各種類型的條碼,例如 QR 碼、Code 128 和 UPC 等。您可以在生成條碼時指定條碼類型。 是否可以準確定位條碼在 PDF 頁面上的位置? 是的,您可以通過指定以像素為單位的 x 和 y 坐標準確定位條碼在 PDF 頁面上的位置,這決定了頁面上的水平和垂直位置。 Hairil Hasyimi Bin Omar 立即與工程團隊聊天 軟體工程師 和所有优秀的工程师一样,Hairil 是个努力学习者。他正在细化自己的 C# 、Python 和 Java 知识,将这些知识应用于 Iron Software 各个团队成员以增加价值。Hairil 自马来西亚 Universiti Teknologi MARA 加入 Iron Software 团队,并以化学与工艺工程学士学位毕业。 準備好開始了嗎? Nuget 下載 1,935,276 | 版本: 2025.11 剛剛發布 免費 NuGet 下載 總下載量:1,935,276 查看許可證