產品比較 發現.net中QuestPDF水印的最佳替代方案 Curtis Chau 更新日期:7月 28, 2025 Download IronPDF NuGet 下載 DLL 下載 Windows 安裝程式 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 浮水印 是 PDF 文件中不可或缺的元素,提供所有權、真實性或保密性的視覺指示。 They can deter unauthorized use and help protect intellectual property, making them crucial for businesses and individuals alike. In this article, we will compare two powerful libraries—IronPDF and QuestPDF—focusing on their capabilities for adding watermarks to PDF files in C#. IronPDF 概述 关键特性 IronPDF 是一個強大的 PDF 庫,開發人員可以無縫創建、編輯和操作 PDF 文件。 與浮水印相關的主要功能包括: 靈活的浮水印功能:支持文字和圖片浮水印,可根據字體、大小、顏色和透明度進行自訂。 易於整合:兼容 .NET 應用程序,使其易於在現有項目中實施。 豐富的格式選項:為 浮水印 提供豐富的樣式選項,增強文件的視覺吸引力。 Conversion Tools: Convert HTML, URL, images, and more into PDF formats. 安裝和設置 要開始使用 IronPDF,請按照以下步驟進行: 在包管理器控制台中運行以下命令 安裝 IronPDF NuGet 包: Install-Package IronPdf 在您的 C# 文件中 添加必要的命名空間: using IronPdf; using IronPdf; Imports IronPdf $vbLabelText $csharpLabel 使用 IronPDF 向 PDF 文件添加浮水印 IronPDF 使用 HTML 字符串和 CSS 樣式來向您的 PDF 文件添加完全自訂的浮水印。 浮水印工具可以採用任何 HTML 字符串,即使它包含資產如圖片和 CSS 樣式,也可以將其應用於 PDF 文件作為浮水印。 using IronPdf; class Program { static void Main() { // Load an existing PDF document. PdfDocument pdf = PdfDocument.FromFile("existing.pdf"); // Define the watermark using HTML and CSS. string watermark = "<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'><h1 style='color:red;'>CONFIDENTIAL</h1>"; // Apply the watermark with specified rotation and opacity. pdf.ApplyWatermark(watermark, rotation: 45, opacity: 80); // Save the watermarked document. pdf.SaveAs("watermarked.pdf"); } } using IronPdf; class Program { static void Main() { // Load an existing PDF document. PdfDocument pdf = PdfDocument.FromFile("existing.pdf"); // Define the watermark using HTML and CSS. string watermark = "<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'><h1 style='color:red;'>CONFIDENTIAL</h1>"; // Apply the watermark with specified rotation and opacity. pdf.ApplyWatermark(watermark, rotation: 45, opacity: 80); // Save the watermarked document. pdf.SaveAs("watermarked.pdf"); } } Imports IronPdf Friend Class Program Shared Sub Main() ' Load an existing PDF document. Dim pdf As PdfDocument = PdfDocument.FromFile("existing.pdf") ' Define the watermark using HTML and CSS. Dim watermark As String = "<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'><h1 style='color:red;'>CONFIDENTIAL</h1>" ' Apply the watermark with specified rotation and opacity. pdf.ApplyWatermark(watermark, rotation:= 45, opacity:= 80) ' Save the watermarked document. pdf.SaveAs("watermarked.pdf") End Sub End Class $vbLabelText $csharpLabel 輸出 PDF 文件 正如您所見,我們創建了一個包含我們浮水印內容的新字符串變量。 這是由包含標題和圖片的 HTML 字符串組成的。 當我們使用 ApplyWatermark 方法時,我們可以設置自訂的旋轉和不透明度。 如果您想查看更多高級示例及其他 IronPDF 提供的功能,請務必查看 操作指南! QuestPDF 概述 关键特性 QuestPDF 是一個現代 PDF 庫,強調易用性和開發者友好的設計。 與浮水印相關的主要功能包括: 宣告式 API:使用流暢的 API,允許開發人員以清晰和直觀的方式定義浮水印。 高度自訂化:支持各種類型的浮水印,包括文本、圖片和形狀,具有廣泛的自訂選項。 性能重視:針對速度和效率進行優化,使其適合高容量 PDF 生成。 安裝和設置 要安裝 QuestPDF,請按照以下步驟進行: 使用以下命令 安裝 QuestPDF NuGet 包: Install-Package QuestPDF Install-Package QuestPDF SHELL 在您的 C# 文件中 包含必要的命名空間: using QuestPDF; using QuestPDF; Imports QuestPDF $vbLabelText $csharpLabel 使用 QuestPDF 添加浮水印 QuestPDF 有一種不同的方法來將浮水印應用於 PDF 文件。 使用 QuestPDF,這是通過浮水印插槽(在背景和前景中)完成的,用來將浮水印內容添加到 PDF 的特定頁面或所有頁面上。 using QuestPDF.Fluent; using QuestPDF.Helpers; using QuestPDF.Infrastructure; public class WatermarkExample { public static void Main() { // Set the license type to Community for QuestPDF. QuestPDF.Settings.License = LicenseType.Community; // Create a PDF document with a defined structure. Document.Create(container => { container.Page(page => { page.Margin(50); // Add a foreground watermark. page.Foreground().Element(watermark => { watermark.Text("DRAFT") .FontSize(40) .FontColor(Colors.Red.Medium) .AlignLeft(); }); // Add the main content of the page. page.Content().Element(ComposeContent); }); }) .GeneratePdf("watermarked_document.pdf"); } private static IContainer ComposeContent(IContainer container) { // Define the layout and content of the PDF. container.Column(column => { column.Spacing(10); column.Item().Text("This is the main content of the PDF."); column.Item().Text("Add more content as needed."); }); return container; // Return the container to maintain method signature. } } using QuestPDF.Fluent; using QuestPDF.Helpers; using QuestPDF.Infrastructure; public class WatermarkExample { public static void Main() { // Set the license type to Community for QuestPDF. QuestPDF.Settings.License = LicenseType.Community; // Create a PDF document with a defined structure. Document.Create(container => { container.Page(page => { page.Margin(50); // Add a foreground watermark. page.Foreground().Element(watermark => { watermark.Text("DRAFT") .FontSize(40) .FontColor(Colors.Red.Medium) .AlignLeft(); }); // Add the main content of the page. page.Content().Element(ComposeContent); }); }) .GeneratePdf("watermarked_document.pdf"); } private static IContainer ComposeContent(IContainer container) { // Define the layout and content of the PDF. container.Column(column => { column.Spacing(10); column.Item().Text("This is the main content of the PDF."); column.Item().Text("Add more content as needed."); }); return container; // Return the container to maintain method signature. } } Imports QuestPDF.Fluent Imports QuestPDF.Helpers Imports QuestPDF.Infrastructure Public Class WatermarkExample Public Shared Sub Main() ' Set the license type to Community for QuestPDF. QuestPDF.Settings.License = LicenseType.Community ' Create a PDF document with a defined structure. Document.Create(Sub(container) container.Page(Sub(page) page.Margin(50) ' Add a foreground watermark. page.Foreground().Element(Sub(watermark) watermark.Text("DRAFT").FontSize(40).FontColor(Colors.Red.Medium).AlignLeft() End Sub) ' Add the main content of the page. page.Content().Element(AddressOf ComposeContent) End Sub) End Sub).GeneratePdf("watermarked_document.pdf") End Sub Private Shared Function ComposeContent(ByVal container As IContainer) As IContainer ' Define the layout and content of the PDF. container.Column(Sub(column) column.Spacing(10) column.Item().Text("This is the main content of the PDF.") column.Item().Text("Add more content as needed.") End Sub) Return container ' Return the container to maintain method signature. End Function End Class $vbLabelText $csharpLabel 輸出 PDF 文檔 在主方法中,我們首先創建一個有50單位邊距的頁面文檔。 然後我們創建我們想要使用的浮水印,即紅色的簡單文本“DRAFT”,樣式為字體大小 40 並左對齊。 與 IronPDF 的流線型方法相比,這種將浮水印應用於 PDF 文件的方法在設置上更為僵硬和複雜。 使用 QuestPDF,您可能對浮水印的外觀和位置控制較少。 浮水印功能比較 易用性 IronPDF 提供了易於理解的方法,附有豐富的文件和示例,使初學者易於上手。 QuestPDF,憑借其宣告式 API,進一步簡化了流程,允許簡潔的代碼,提高生產力。 自定义选项 這兩個庫均提供了對浮水印的廣泛自訂。 IronPDF 允許對文本和圖片進行詳細的樣式設計,而 QuestPDF 提供更靈活的元素排列方式,並支持復雜設計,使其適合創意應用。 性能 就性能而言,兩個庫的表現都很好,但 QuestPDF 可能由於其高效設計而在速度上有優勢。 建議在實際場景中測試這些庫,以確定最適合您特定使用情況的庫。 授權和定價 IronPDF 許可選項 IronPDF 採用 商業授權模式。 QuestPDF 許可選項 QuestPDF 提供開源許可,並可選擇商業支持。 這使得它成為開發人員尋求強大功能而不需大規模經濟承擔的經濟選擇。 結論 !探索 QuestPDF 浮水印在 .NET 中的最佳替代品:圖 5 IronPDF 和 QuestPDF 均是用於在 C# 中向 PDF 添加浮水印的強大庫。 IronPDF 在詳細的自訂選項及用戶友好的方法上表現出色,非常適合需要特定格式的用戶。 反之,QuestPDF 憑借其現代 API 設計和性能效率而突出,吸引尋求快速直觀解決方案的開發人員。 對於需要廣泛自訂的場景,IronPDF 可能是首選。相反,QuestPDF 適合於優先考慮速度和易用性的項目。 通过下载免费试用来亲自尝试IronPDF,探索它如何将您的C# PDF项目提升到新水平! 請注意QuestPDF是其相應所有者的註冊商標。 此網站與QuestPDF無關,未經其認可或贊助。 所有產品名稱、徽標和品牌均為其各自所有者的財產。 比較僅供信息參考,並反映撰寫時公開可用的信息。 常見問題解答 如何在 C# 中向 PDF 添加浮水印? 您可以使用 IronPDF 在 C# 中通過定義帶有 HTML 和 CSS 的浮水印來向 PDF 添加浮水印。可以使用 ApplyWatermark 方法應用浮水印,允許在旋轉和不透明度方面進行定製。 應使用哪個 PDF 庫進行大量浮水印定制? 對於大量浮水印定制,推薦使用 IronPDF。它提供使用 HTML 和 CSS 進行詳細樣式設置,理想用於複雜的浮水印設計。 IronPDF 如何處理 PDF 浮水印? IronPDF 通過允許用戶使用可定製的樣式應用文本或圖像浮水印來處理 PDF 浮水印。這種靈活性使得浮水印的外觀精確可控。 使用 IronPDF 對於 PDF 添加浮水印有哪些優勢? 使用 IronPDF 添加 PDF 浮水印的優勢包括與 .NET 應用的集成、支持浮水印的 HTML 和 CSS 样式以及轉換多種格式為 PDF 的能力。 如何在 .NET 中安裝 PDF 庫以添加浮水印? 要在 .NET 中安裝像 IronPDF 的 PDF 庫以添加浮水印,請使用 NuGet 包管理器並在您的包管理器控制台中運行命令Install-Package IronPdf。 我可以使用 QuestPDF 向 PDF 添加浮水印嗎? 是的,QuestPDF 可以使用浮水印插槽來添加浮水印,允許將文本和其他元素定位在特定頁面或整個文檔中。 IronPDF 和 QuestPDF 在浮水印處理上的不同之處? IronPDF 提供豐富的 HTML 和 CSS 樣式用於詳細的浮水印定製,而 QuestPDF 提供現代聲明式 API 和元素佈局的靈活性,適合創意佈局。 IronPDF 有免費試用版嗎? 是的,IronPDF 提供免費試用版,允許您探索其在 C# 項目中添加浮水印和其他 PDF 操作的功能。 哪個 PDF 庫最適合高性能浮水印處理? QuestPDF 以其性能優化而聞名,適合速度是關鍵因素的項目。 IronPDF 的許可選擇有哪些? IronPDF 採用商業許可模式,提供多種選擇以滿足不同開發者對強大 PDF 功能的需求。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 相關文章 發表日期 11月 13, 2025 C# HTML 與 PDF 開源版本比較 IronPDF 將開源 HTML 轉 PDF 庫與 IronPDF for C# 進行比較。探索哪種解決方案能為您的 .NET 專案提供最佳的 PDF 生成功能。 閱讀更多 發表日期 10月 27, 2025 哪個 ASP.NET Core PDF 庫具有最佳價值? 發現適用於 ASP.NET Core 應用程式的最佳 PDF 庫。比較 IronPDF 的 Chrome 引擎與 Aspose 和 Syncfusion 的替代方案。 閱讀更多 發表日期 10月 27, 2025 如何使用 Aspose C# 和 IronPDF 創建 PDF 通過這份針對開發人員設計的分步指南,學習如何使用 Aspose C# 與 IronPDF 創建 PDF。 閱讀更多 從Aspose PDF遷移到IronPDF:(完整比較)探索PDFsharp向PDF添加水印的...
發表日期 11月 13, 2025 C# HTML 與 PDF 開源版本比較 IronPDF 將開源 HTML 轉 PDF 庫與 IronPDF for C# 進行比較。探索哪種解決方案能為您的 .NET 專案提供最佳的 PDF 生成功能。 閱讀更多
發表日期 10月 27, 2025 哪個 ASP.NET Core PDF 庫具有最佳價值? 發現適用於 ASP.NET Core 應用程式的最佳 PDF 庫。比較 IronPDF 的 Chrome 引擎與 Aspose 和 Syncfusion 的替代方案。 閱讀更多
發表日期 10月 27, 2025 如何使用 Aspose C# 和 IronPDF 創建 PDF 通過這份針對開發人員設計的分步指南,學習如何使用 Aspose C# 與 IronPDF 創建 PDF。 閱讀更多