產品比較 IronPDF與PDFShift之間的比較 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)是最受歡迎的文件格式,可以用於在單個文件中表示文本、鏈接、按鈕、圖形和更多內容。 在C#編程語言中操作PDF幾乎是不可能的,除非使用PDF API for C#。 本文將探討如何使用兩種不同的API來交互和操作PDF文檔,並比較這兩個API的性能、特性和許可。 我們將在本文中討論的PDF API有: IronPDF PDFShift 1. IronPDF IronPDF是一個強大的HTML轉PDF轉換API。 IronPDF是.NET和.NET Core開發中轉換HTML網站的理想解決方案。 它不僅可以轉換HTML,還有各種附加功能。 IronPDF允許開發人員在.NET Core和.NET Framework項目中創建、修改和檢索PDF文檔。 使用IronPDF包,開發人員可以輕鬆地從HTML頁面生成或更改PDF。 PDF可以輕鬆編輯、加蓋印章,並添加頁眉和頁腳。 它還使閱讀PDF文本和提取圖片變得非常簡單。 IronPDF使用.NET Chromium引擎將HTML頁面渲染為PDF文件。 1.1. IronPDF功能 1.1.1. PDF轉換 此功能包括從不同格式創建 PDF,例如 HTML、HTML 字串、MVC 視圖、網頁表單和 URL。 1.1.2. PDF成像 這允許用戶從PDF創建圖像並從圖像創建PDF。 它包括圖像提取、支持不同的圖像擴展以及 PDF 打印。 1.1.3. PDF文件I/O IronPDF還提供128位加密、密碼鎖定和數字簽名功能。 1.1.4. 編輯PDF IronPDF的這個功能可以進行所有類型的PDF格式化,例如添加水印、添加頁面、刪除頁面、添加背景、添加前景等。 簡而言之,IronPDF 提供了操作 PDF 所需的所有功能。 1.1.5. PDF內容提取 在許多情況下,您可以直接從 PDF 中提取嵌入的文本。 如果這不行,你的文本可能實際上嵌入在圖像中。 使用IronOCR庫掃描文檔以獲取視覺文本,而不是純文本。 1.1.6. 頁眉和頁腳 在創建PDF時或將其添加到現有的PDF時可以添加頁眉和頁腳。 打印選項屬性允許您為每個文檔頁面製作頁眉和頁腳。 在 Chrome PDF 渲染器對象上訪問這些選項。 這個示例在.NET Core控制台應用程序中工作。 1.1.7. 相容性 IronPDF 支持幾乎所有與 C# 兼容的操作系統和框架,包括以下: Windows Linux .NET Core 2.1、3.0、3.1、.NET 6 和 5 .NET Standard 2.0 通用兼容性 Microsoft Azure Amazon Web Services (AWS) Docker 2. PDFShift PDFShift是一個HTML轉PDF轉換API工具,使組織能夠在幾秒鐘內將HTML頁面轉換為PDF。 通過基於雲服務器的API工具,可以進行並行轉換、異步查詢、原始HTML支持和其他功能。 PDFShift是一個簡單易用的解決方案,支持Ruby、Python、JavaScript、Node和PHP等多種開發者語言,以便於轉換過程。 PDFShift允許客戶設置自定義的頁眉和頁腳、應用自定義CSS、加密文件等,使企業對轉換完全掌控。 2.1. PDFShift功能 2.1.1. 並行轉換 PDFShift支持並行轉換,允許用戶同時轉換多個文檔,以提高轉換速度。 2.1.2. 高級頁眉和頁腳選項 創建具有頁碼的自定義頁眉和頁腳,使用自定義CSS和JavaScript,加密文件等。 2.1.3. 原始HTML數據到PDF轉換API PDFShift支持原始HTML到PDF轉換,不公開頁面。 2.1.4. 高精準PDF PDFShift將HTML轉換為高保真PDF文檔只需幾秒鐘。 2.1.5. 異步請求 要在轉換完成時獲得提醒,請使用我們的高級實時系統。 使用強大的PDFShift API將HTML轉換為PDF,並僅需三行代碼即可集成系統。 3. 在Visual Studio中創建新項目 打開 Visual Studio 軟件,然後轉到「文件」菜單。 選擇“新項目”,然後選擇控制台應用程序。 在本文中,我們將使用控制台應用程序來生成 PDF 文檔。 輸入項目名稱並在適當的文本框中選擇路徑。 然後,單擊創建按鈕。 選擇所需的 .NET 框架,如下面的截圖所示: class="content-img-align-center"> Visual Studio項目現在將生成所選應用程序的結構,如果您選擇了控制台、Windows和Web應用程序,它將打開program.cs文件,您可以在其中輸入代碼並構建/運行應用程序。 class="content-img-align-center"> 現在我們可以添加庫並測試程序。 4. 安裝IronPDF庫 IronPDF 庫可以通過四種不同的方式下載和安裝。 這些是: 使用 Visual Studio NuGet 套件管理器 使用 Visual Studio 命令行 直接從NuGet網頁下載 直接從IronPDF網頁下載 4.1 使用Visual Studio NuGet包管理器 Visual Studio 軟件提供 NuGet 包管理器選項,允許將包直接安裝到解決方案中。 下面的截圖顯示了如何打開 NuGet 包管理器。 class="content-img-align-center"> 它提供了一個搜索框來顯示來自NuGet網站的可用包庫列表。在包管理器中,我們需要搜索關鍵詞“IronPDF”,如下圖所示 class="content-img-align-center"> 在上圖中,我們可以看到搜尋到的相關套件列表。 我們需要選擇 IronPDF 選项並將套件安裝到我們的解決方案中。 4.2 使用 Visual Studio 命令行 在Visual Studio菜單中,轉到工具 > NuGet包管理器 > 包管理器控制台 class="content-img-align-center"> 在包管理器控制台標籤中輸入以下行: Install-Package IronPdf 現在,包將下載/安裝到當前項目中,並可以使用。 class="content-img-align-center"> 4.3 直接從NuGet網頁下載 第三種方法是直接從網頁下載NuGet包。 瀏覽到 NuGet IronPDF包網頁 從右側菜單中選擇下載包的選項。 雙擊下載的套件; 它將自動安裝。 現在重新加載解決方案並開始在項目中使用它。 4.4 直接從IronPDF網頁下載 從 IronPDF 下載頁面直接下載最新的包。 下載後,按照以下步驟將包添加到項目中。 從解決方案窗口中右鍵單擊項目。 然後,選擇選項參考,並瀏覽下載參考的位置。 接下來,點擊 OK 添加參考。 5. PDFShift工作原理 PDFShift不能集成到項目中 —— 而是可以遠程運行。 您需要使用C# RestClient包提交POST請求給PDFShift的API,只需將您的API密鑰作為簡單身份驗證的用戶參數給出。 服務器收到您的請求,處理並返回輸出文件,所有PDF轉換API的工作都通過HTTP post請求完成。PDFShift提供多語言API,並為其所有提供遠程工作。 6. 從HTML創建PDF 這兩個工具都包含這一HTML轉換功能,儘管它們的方式略有不同。 6.1. 使用IronPDF從URL創建PDF 在C#中使用URL創建PDF文件就如同上面的示例一樣簡單,只需這三行代碼。 以下代碼將演示如何從URL創建PDF文件。 using IronPdf; var Renderer = new IronPdf.ChromePdfRenderer(); // Create a PDF from a URL or local file path using var pdf = Renderer.RenderUrlAsPdf("https://www.amazon.com/?tag=hp2-brobookmark-us-20"); // Export to a file or Stream pdf.SaveAs("url.pdf"); using IronPdf; var Renderer = new IronPdf.ChromePdfRenderer(); // Create a PDF from a URL or local file path using var pdf = Renderer.RenderUrlAsPdf("https://www.amazon.com/?tag=hp2-brobookmark-us-20"); // Export to a file or Stream pdf.SaveAs("url.pdf"); Imports IronPdf Private Renderer = New IronPdf.ChromePdfRenderer() ' Create a PDF from a URL or local file path Private pdf = Renderer.RenderUrlAsPdf("https://www.amazon.com/?tag=hp2-brobookmark-us-20") ' Export to a file or Stream pdf.SaveAs("url.pdf") $vbLabelText $csharpLabel 以下是上面代碼的輸出。 class="content-img-align-center"> 6.2. 使用IronPDF將HTML轉換為PDF 使用 IronPDF C# .NET 庫將 HTML 轉換為 PDF 非常簡便。 using IronPdf; var pdf = new ChromePdfRenderer(); PdfDocument doc = pdf.RenderHtmlAsPdf("<h1>This is a heading</h1>"); doc.SaveAs("FirstPDFDocument.pdf"); using IronPdf; var pdf = new ChromePdfRenderer(); PdfDocument doc = pdf.RenderHtmlAsPdf("<h1>This is a heading</h1>"); doc.SaveAs("FirstPDFDocument.pdf"); Imports IronPdf Private pdf = New ChromePdfRenderer() Private doc As PdfDocument = pdf.RenderHtmlAsPdf("<h1>This is a heading</h1>") doc.SaveAs("FirstPDFDocument.pdf") $vbLabelText $csharpLabel class="content-img-align-center"> 6.3. 使用PDFShift從URL創建PDF 使用PDFShift轉換URL非常簡單。 您只需按照以下方式發送帶有source參數設置為URL的POST請求: using System; using RestSharp; using RestSharp.Authenticators; using System.IO; namespace PDFShiftExample { class Program { static void Main(string[] args) { var client = new RestClient("https://api.pdfshift.io/v3/convert/pdf"); client.Authenticator = new HttpBasicAuthenticator("api", "your_api_key"); var request = new RestRequest(Method.POST); var json = new { source = "https://www.example.com" }; request.AddJsonBody(json); var response = client.Execute(request); if (!response.IsSuccessful) { // Handle the unsuccessful response } else { File.WriteAllBytes("result.pdf", response.RawBytes); } } } } using System; using RestSharp; using RestSharp.Authenticators; using System.IO; namespace PDFShiftExample { class Program { static void Main(string[] args) { var client = new RestClient("https://api.pdfshift.io/v3/convert/pdf"); client.Authenticator = new HttpBasicAuthenticator("api", "your_api_key"); var request = new RestRequest(Method.POST); var json = new { source = "https://www.example.com" }; request.AddJsonBody(json); var response = client.Execute(request); if (!response.IsSuccessful) { // Handle the unsuccessful response } else { File.WriteAllBytes("result.pdf", response.RawBytes); } } } } Imports System Imports RestSharp Imports RestSharp.Authenticators Imports System.IO Namespace PDFShiftExample Friend Class Program Shared Sub Main(ByVal args() As String) Dim client = New RestClient("https://api.pdfshift.io/v3/convert/pdf") client.Authenticator = New HttpBasicAuthenticator("api", "your_api_key") Dim request = New RestRequest(Method.POST) Dim json = New With {Key .source = "https://www.example.com"} request.AddJsonBody(json) Dim response = client.Execute(request) If Not response.IsSuccessful Then ' Handle the unsuccessful response Else File.WriteAllBytes("result.pdf", response.RawBytes) End If End Sub End Class End Namespace $vbLabelText $csharpLabel 6.4. 使用PDFShift將HTML轉換為PDF PDFShift還提供HTML-to-PDF直接轉換,但從HTML文件中讀取HTML內容。 using System; using System.IO; using RestSharp; using RestSharp.Authenticators; namespace PDFShiftExample { class Program { static void Main(string[] args) { var client = new RestClient("https://api.pdfshift.io/v3/convert/pdf"); client.Authenticator = new HttpBasicAuthenticator("api", "your_api_key"); var request = new RestRequest(Method.POST); string documentContent = File.ReadAllText("document.html"); var json = new { source = documentContent }; request.AddJsonBody(json); var response = client.Execute(request); if (!response.IsSuccessful) { // Handle the unsuccessful response } else { File.WriteAllBytes("result.pdf", response.RawBytes); } } } } using System; using System.IO; using RestSharp; using RestSharp.Authenticators; namespace PDFShiftExample { class Program { static void Main(string[] args) { var client = new RestClient("https://api.pdfshift.io/v3/convert/pdf"); client.Authenticator = new HttpBasicAuthenticator("api", "your_api_key"); var request = new RestRequest(Method.POST); string documentContent = File.ReadAllText("document.html"); var json = new { source = documentContent }; request.AddJsonBody(json); var response = client.Execute(request); if (!response.IsSuccessful) { // Handle the unsuccessful response } else { File.WriteAllBytes("result.pdf", response.RawBytes); } } } } Imports System Imports System.IO Imports RestSharp Imports RestSharp.Authenticators Namespace PDFShiftExample Friend Class Program Shared Sub Main(ByVal args() As String) Dim client = New RestClient("https://api.pdfshift.io/v3/convert/pdf") client.Authenticator = New HttpBasicAuthenticator("api", "your_api_key") Dim request = New RestRequest(Method.POST) Dim documentContent As String = File.ReadAllText("document.html") Dim json = New With {Key .source = documentContent} request.AddJsonBody(json) Dim response = client.Execute(request) If Not response.IsSuccessful Then ' Handle the unsuccessful response Else File.WriteAllBytes("result.pdf", response.RawBytes) End If End Sub End Class End Namespace $vbLabelText $csharpLabel 7. 自定義頁眉和頁腳 在處理PDF時,添加頁眉和頁腳是必須的。 討論中的兩個工具都支持此選項。 7.1. 使用IronPDF的自定義頁眉和頁腳 使用IronPDF您可以以兩種不同的方式添加頁眉和頁腳。 TextHeaderFooter允許添加基於文字的頁眉,並有選項合併動態數據。 HtmlHeaderFooter允許開發人員將HTML頁眉和頁腳渲染為PDF文件,還允許動態數據的模板化。 它更靈活但更難使用。 using IronPdf; var Renderer = new IronPdf.ChromePdfRenderer(); Renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a coverpage will be appended Renderer.RenderingOptions.TextHeader.DrawDividerLine = true; Renderer.RenderingOptions.TextHeader.CenterText = "{url}"; Renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica; Renderer.RenderingOptions.TextHeader.FontSize = 12; using IronPdf; var Renderer = new IronPdf.ChromePdfRenderer(); Renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a coverpage will be appended Renderer.RenderingOptions.TextHeader.DrawDividerLine = true; Renderer.RenderingOptions.TextHeader.CenterText = "{url}"; Renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica; Renderer.RenderingOptions.TextHeader.FontSize = 12; Imports IronPdf Private Renderer = New IronPdf.ChromePdfRenderer() Renderer.RenderingOptions.FirstPageNumber = 1 ' use 2 if a coverpage will be appended Renderer.RenderingOptions.TextHeader.DrawDividerLine = True Renderer.RenderingOptions.TextHeader.CenterText = "{url}" Renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica Renderer.RenderingOptions.TextHeader.FontSize = 12 $vbLabelText $csharpLabel 7.2. 使用PDFShift的自定義頁眉和頁腳 通過添加自定義頁眉或頁腳來自定義生成的文檔。 這些經常用於標識當前頁面或在每頁上顯示公司的標誌。 using System; using RestSharp; using RestSharp.Authenticators; using System.IO; namespace PDFShiftExample { class Program { static void Main(string[] args) { var client = new RestClient("https://api.pdfshift.io/v3/convert/pdf"); client.Authenticator = new HttpBasicAuthenticator("api", "your_api_key"); var request = new RestRequest(Method.POST); var json = new { source = "https://quillbot.com/", footer = new { source = "<div style=\"font-size: 12px\">Page {{page}} of {{total}}</div>", spacing = "50px" } }; request.AddJsonBody(json); var response = client.Execute(request); if (!response.IsSuccessful) { // Handle the unsuccessful response } else { File.WriteAllBytes("result.pdf", response.RawBytes); } } } } using System; using RestSharp; using RestSharp.Authenticators; using System.IO; namespace PDFShiftExample { class Program { static void Main(string[] args) { var client = new RestClient("https://api.pdfshift.io/v3/convert/pdf"); client.Authenticator = new HttpBasicAuthenticator("api", "your_api_key"); var request = new RestRequest(Method.POST); var json = new { source = "https://quillbot.com/", footer = new { source = "<div style=\"font-size: 12px\">Page {{page}} of {{total}}</div>", spacing = "50px" } }; request.AddJsonBody(json); var response = client.Execute(request); if (!response.IsSuccessful) { // Handle the unsuccessful response } else { File.WriteAllBytes("result.pdf", response.RawBytes); } } } } Imports System Imports RestSharp Imports RestSharp.Authenticators Imports System.IO Namespace PDFShiftExample Friend Class Program Shared Sub Main(ByVal args() As String) Dim client = New RestClient("https://api.pdfshift.io/v3/convert/pdf") client.Authenticator = New HttpBasicAuthenticator("api", "your_api_key") Dim request = New RestRequest(Method.POST) Dim json = New With { Key .source = "https://quillbot.com/", Key .footer = New With { Key .source = "<div style=""font-size: 12px"">Page {{page}} of {{total}}</div>", Key .spacing = "50px" } } request.AddJsonBody(json) Dim response = client.Execute(request) If Not response.IsSuccessful Then ' Handle the unsuccessful response Else File.WriteAllBytes("result.pdf", response.RawBytes) End If End Sub End Class End Namespace $vbLabelText $csharpLabel 9. 水印 使用編程語言為PDF添加水印是相當困難的一項工作。 IronPDF和PDFShift都支持為PDF添加水印。 9.1. 使用IronPDF添加水印 IronPDF提供“水印”PDF文檔與HTML的方法。 水印可以設置為在現有內容上方或下方渲染,並內建不透明度、旋轉和超鏈接功能。 using IronPdf; var Renderer = new IronPdf.ChromePdfRenderer(); using var Pdf = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf"); Pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>", IronPdf.Editing.WaterMarkLocation.MiddleCenter, 50, -45, "https://www.nuget.org/packages/IronPdf"); Pdf.SaveAs(@"C:\Path\To\Watermarked.pdf"); using IronPdf; var Renderer = new IronPdf.ChromePdfRenderer(); using var Pdf = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf"); Pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>", IronPdf.Editing.WaterMarkLocation.MiddleCenter, 50, -45, "https://www.nuget.org/packages/IronPdf"); Pdf.SaveAs(@"C:\Path\To\Watermarked.pdf"); Imports IronPdf Private Renderer = New IronPdf.ChromePdfRenderer() Private Pdf = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf") Pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>", IronPdf.Editing.WaterMarkLocation.MiddleCenter, 50, -45, "https://www.nuget.org/packages/IronPdf") Pdf.SaveAs("C:\Path\To\Watermarked.pdf") $vbLabelText $csharpLabel class="content-img-align-center"> 9.2. 使用PDFShift添加水印 用戶需要水印以清晰地識別在PDF中。 using System; using RestSharp; using RestSharp.Authenticators; using System.IO; namespace PDFShiftExample { class Program { static void Main(string[] args) { var client = new RestClient("https://api.pdfshift.io/v3/convert/pdf"); client.Authenticator = new HttpBasicAuthenticator("api", "your_api_key"); var request = new RestRequest(Method.POST); var json = new { source = "https://www.example.com", watermark = new { image = "https://pdfshift-dev.netlify.com/images/logo/logo-violet.png", offset_x = 50, offset_y = "100px", rotate = 45 } }; request.AddJsonBody(json); var response = client.Execute(request); if (!response.IsSuccessful) { // Handle the unsuccessful response } else { File.WriteAllBytes("result.pdf", response.RawBytes); } } } } using System; using RestSharp; using RestSharp.Authenticators; using System.IO; namespace PDFShiftExample { class Program { static void Main(string[] args) { var client = new RestClient("https://api.pdfshift.io/v3/convert/pdf"); client.Authenticator = new HttpBasicAuthenticator("api", "your_api_key"); var request = new RestRequest(Method.POST); var json = new { source = "https://www.example.com", watermark = new { image = "https://pdfshift-dev.netlify.com/images/logo/logo-violet.png", offset_x = 50, offset_y = "100px", rotate = 45 } }; request.AddJsonBody(json); var response = client.Execute(request); if (!response.IsSuccessful) { // Handle the unsuccessful response } else { File.WriteAllBytes("result.pdf", response.RawBytes); } } } } Imports System Imports RestSharp Imports RestSharp.Authenticators Imports System.IO Namespace PDFShiftExample Friend Class Program Shared Sub Main(ByVal args() As String) Dim client = New RestClient("https://api.pdfshift.io/v3/convert/pdf") client.Authenticator = New HttpBasicAuthenticator("api", "your_api_key") Dim request = New RestRequest(Method.POST) Dim json = New With { Key .source = "https://www.example.com", Key .watermark = New With { Key .image = "https://pdfshift-dev.netlify.com/images/logo/logo-violet.png", Key .offset_x = 50, Key .offset_y = "100px", Key .rotate = 45 } } request.AddJsonBody(json) Dim response = client.Execute(request) If Not response.IsSuccessful Then ' Handle the unsuccessful response Else File.WriteAllBytes("result.pdf", response.RawBytes) End If End Sub End Class End Namespace $vbLabelText $csharpLabel 8. Bootstrap和現代CSS框架支持 現代Web開發嚴重依賴於像Bootstrap這樣的CSS框架來實現快速UI開發和響應式設計。 PDF庫必須準確轉換這些框架以保持專業的文檔質量。 IronPDF:全面的Bootstrap和框架支持 IronPDF的Chromium引擎提供對現代CSS框架的全面支持: Bootstrap 5:完整的flexbox和CSS網格,帶有響應式實用工具 Bootstrap 4:完整的卡片系統、導航、表單組件 Tailwind CSS:所有實用類和響應修飾符 Foundation:完整的網格和組件系統 現代 CSS3: Flexbox, Grid, 自定義屬性, 動畫, 轉換 Real-world validation: Bootstrap homepage and Bootstrap templates convert with pixel-perfect accuracy. 代碼示例:帶有Bootstrap的聯繫表單 using IronPdf; var renderer = new ChromePdfRenderer(); string bootstrapContact = @" <!DOCTYPE html> <html> <head> <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'> </head> <body> <div class='container my-5'> <div class='row justify-content-center'> <div class='col-lg-8'> <div class='card shadow'> <div class='card-header bg-primary text-white'> <h2 class='mb-0'>Contact Us</h2> </div> <div class='card-body'> <form> <div class='row g-3'> <div class='col-md-6'> <label class='form-label'>First Name</label> <input type='text' class='form-control' placeholder='John'> </div> <div class='col-md-6'> <label class='form-label'>Last Name</label> <input type='text' class='form-control' placeholder='Doe'> </div> </div> <div class='mt-3'> <label class='form-label'>Email Address</label> <div class='input-group'> <span class='input-group-text'>@</span> <input type='email' class='form-control' placeholder='john.doe@example.com'> </div> </div> <div class='mt-3'> <label class='form-label'>Subject</label> <select class='form-select'> <option>General Inquiry</option> <option>Technical Support</option> <option>Sales Question</option> <option>Partnership Opportunity</option> </select> </div> <div class='mt-3'> <label class='form-label'>Message</label> <textarea class='form-control' rows='5' placeholder='Your message here...'></textarea> </div> <div class='d-flex justify-content-between align-items-center mt-4'> <div class='form-check'> <input class='form-check-input' type='checkbox' id='newsletter'> <label class='form-check-label' for='newsletter'> Subscribe to newsletter </label> </div> <button type='submit' class='btn btn-primary px-4'>Submit</button> </div> </form> </div> </div> <div class='alert alert-info mt-4 d-flex align-items-center' role='alert'> <svg class='bi flex-shrink-0 me-2' width='24' height='24'></svg> <div>We typically respond within 24 hours during business days.</div> </div> </div> </div> </div> </body> </html>"; var pdf = renderer.RenderHtmlAsPdf(bootstrapContact); pdf.SaveAs("contact-form.pdf"); using IronPdf; var renderer = new ChromePdfRenderer(); string bootstrapContact = @" <!DOCTYPE html> <html> <head> <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'> </head> <body> <div class='container my-5'> <div class='row justify-content-center'> <div class='col-lg-8'> <div class='card shadow'> <div class='card-header bg-primary text-white'> <h2 class='mb-0'>Contact Us</h2> </div> <div class='card-body'> <form> <div class='row g-3'> <div class='col-md-6'> <label class='form-label'>First Name</label> <input type='text' class='form-control' placeholder='John'> </div> <div class='col-md-6'> <label class='form-label'>Last Name</label> <input type='text' class='form-control' placeholder='Doe'> </div> </div> <div class='mt-3'> <label class='form-label'>Email Address</label> <div class='input-group'> <span class='input-group-text'>@</span> <input type='email' class='form-control' placeholder='john.doe@example.com'> </div> </div> <div class='mt-3'> <label class='form-label'>Subject</label> <select class='form-select'> <option>General Inquiry</option> <option>Technical Support</option> <option>Sales Question</option> <option>Partnership Opportunity</option> </select> </div> <div class='mt-3'> <label class='form-label'>Message</label> <textarea class='form-control' rows='5' placeholder='Your message here...'></textarea> </div> <div class='d-flex justify-content-between align-items-center mt-4'> <div class='form-check'> <input class='form-check-input' type='checkbox' id='newsletter'> <label class='form-check-label' for='newsletter'> Subscribe to newsletter </label> </div> <button type='submit' class='btn btn-primary px-4'>Submit</button> </div> </form> </div> </div> <div class='alert alert-info mt-4 d-flex align-items-center' role='alert'> <svg class='bi flex-shrink-0 me-2' width='24' height='24'></svg> <div>We typically respond within 24 hours during business days.</div> </div> </div> </div> </div> </body> </html>"; var pdf = renderer.RenderHtmlAsPdf(bootstrapContact); pdf.SaveAs("contact-form.pdf"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel 輸出:一個專業的聯繫表單,使用Bootstrap的表單控制、網格佈局、卡片樣式和輸入組——全部準確渲染在PDF中。 PDFShift:基於雲的服務與良好的Bootstrap支持 PDFShift是基於雲的API服務,提供HTML到PDF轉換,具有良好的Bootstrap支持: 雲API:所有轉換通過HTTP API調用到PDFShift服務器 Bootstrap支持:通常很好地處理Bootstrap 4/5佈局 CSS3支持:良好的flexbox和現代CSS渲染 需要互聯網:不能離線生成PDF 按文檔計費:按轉換計費,而不是按開發者許可計費 PDFShift的關鍵考量: 外部依賴:所有PDF生成需要互聯網和外部API可用性 數據隱私:HTML內容發送到第三方服務器進行處理 批量成本:按文檔計費在規模上可能變得昂貴 延遲:網絡往返為每次轉換增加延遲 無法離線操作:不能在隔離網絡或離線環境工作 開發影響:雖然PDFShift很好地處理Bootstrap,但雲架構引入了一些運營權衡: 持續的按文檔成本 vs IronPDF的一次性按開發者許可 外部服務依賴 vs 本地內部處理 處理敏感內容所需的數據處理考量 4.互聯網連接需求 vs 離線能力 對於高容量應用、內部要求或敏感數據處理,IronPDF的本地處理模式提供了更好的長期控制和價值。 有關Bootstrap的最佳實踐,請參閱Bootstrap & Flexbox CSS指南。 9. 許可證 IronPDF 是一個提供免費開發人員許可證的庫。 IronPDF還提供特殊價格結構:輕量包從$799開始,沒有隱藏費用。 還可以重新分發 SaaS 和 OEM 產品。 所有許可證均包括 30 天的退款保證、一年的軟件支持和升級、開發/測試/暫存/生產有效性和永久許可證(一次性購買)。 IronPDF許可提供最大化性能以滿足用戶需求。 訪問此鏈接查看IronPDF的完整價格結構和許可信息。 class="content-img-align-center"> PDFShift PDF轉換API提供五種不同的許可計劃,按月和按年進行。 系統使用“積分”來購買各種計劃,其詳細資訊如下: 免費包(每月50個積分) 啟動(每月500個積分為$9,或每年6000個積分為$99) 提升(每月2,500個積分為$24,或每年30,000個積分為$240) 增長(每月5,000個積分為$39,或每年60,000個積分為$390) 商業(每月25,000個積分為$99) 還有文件大小限制:免費包的限制為每個文件1MB,而其他包則限制為每個文件5MB。 class="content-img-align-center"> 有關更多信息和價格,請訪問PDFShift定價頁面。 10. 結論 IronPDF是一款為獨立開發者免費提供的應用程序,提供各種功能和修改PDF文件的能力,以及將其轉換為其他格式。 IronPDF提供了PDF處理的最佳編輯和格式化工具。 它將HTML-to-PDF轉換結果轉換為適合高品質商業印刷的矢量文件。 因此,您將獲得清晰和高質量的PDF。 有關詳細信息,請查看Iron Software許可和價格信息。 PDFShift是一個高質量、高保真、強大的HTML-to-PDF轉換API。 它提供了一個易於學習的端點,具有一組完整功能的工具,以及適用於多種語言的包。 PDFShift使用postMessage將請求發送到可以處理文檔並行轉換的服務器——這意味著您可以同時轉換多個文檔。 IronPDF許可是基於開發者的,這意味著您應該根據將要使用該產品的開發者數量購買許可。 而PDFShift許可則是基於月度和年度計分制,這意味著您將根據訂閱的計劃每月獲得指定的積分。 IronPDF支持OME和SaaS分發,而 PDFShift不支持。 IronPDF許可是一次性購買,您可以終身使用,而PDFShift則提供每月和每年許可。 經過對這兩種工具的快速比較,我們可以得出結論,IronPDF庫提供的功能比PDFShift要多得多。 PDFShift只提供少量操作PDF的功能。 IronPDF只需三行代碼就可以將URL轉換為PDF,但PDFShift需要更多行代碼才能執行相同的任務。 集成IronPDF很容易,隻需幾分鐘就可以完成。 PDFShift在基於雲的系統中工作,不需要集成; 然而,它依賴於其他API,例如RestSharp,因此實際上是一個複雜的過程。 此外,Iron Software目前正在提供五件工具包價格僅為兩件。 Iron Suite 中包含的工具有: IronBarcode IronXL IronOCR IronPDF IronWebScraper 請訪問此Iron Suite頁面來探索IRONSUITE。 請注意PDFShift是其相應擁有者的註冊商標。 本網站與PDFShift無任何關聯、認可或贊助。 所有產品名稱、徽標和品牌均為其各自所有者的財產。 比較僅供信息參考,並反映撰寫時公開可用的信息。 常見問題解答 怎樣在 C# 中將 HTML 轉換為 PDF? 您可以使用 IronPDF 的 RenderHtmlAsPdf 方法將 HTML 字符串轉換為 PDF。您還可以使用 RenderHtmlFileAsPdf 將 HTML 文件轉換為 PDF。 使用 IronPDF 进行 PDF 操作的好处是什么? IronPDF 提供一套強大的 PDF 操作功能,包括從多種格式創建 PDF、圖像提取、加密、編輯能力,並兼容 Windows、Linux 和 Azure、AWS 等雲服務。 PDFShift 的主要功能是什麼? PDFShift 是一個基於雲的 API,支持快速 HTML 到 PDF 的轉換,具有並行轉換、自定義標頭、異步請求和多編程語言的兼容性等功能。 IronPDF 和 PDFShift 在許可方面有何不同? IronPDF 提供基於開發人員的許可,僅需一次性購買且有30天退款保證。相比之下,PDFShift 使用基於信用的許可系統,包括每月和每年的計劃。 IronPDF 可以在雲環境中使用嗎? 可以,IronPDF 支持 Microsoft Azure 和 AWS 等雲環境,使其在不同的部署場景中具有多樣性。 如何使用 IronPDF 將標頭和頁尾添加到 PDF? IronPDF 允許您使用其內建方法向 PDF 添加標頭和頁尾,可自定義以包含文字、圖像或頁碼。 IronPDF 支持哪些平台? IronPDF支持幾乎所有與 C# 兼容的操作系統和框架,包括 Windows、Linux、.NET Core,也可以在雲環境中使用。 如何在我的 Visual Studio 專案中安裝 IronPDF? IronPDF 可以使用 Visual Studio NuGet Package Manager、Visual Studio Command-Line 安裝或者直接從 NuGet 或 IronPDF 頁面下載。 使用 IronPDF 從 PDF 中提取圖像是否可能? 是的,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。 閱讀更多 IronPDF與NReco .NET Core之間的比較IronPDF和SautinSoft PDF Focus之...
發表日期 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。 閱讀更多