觀看David Jones, Agorus, 使用Iron Suite創造新效能
觀看Milan Jovanović使用IronPDF
觀看我們的團隊產品演示
@using IronPdf; public void ExportData() { try { string fileName = "Demo.pdf"; var Renderer = new IronPdf.ChromePdfRenderer(); var pdf = Renderer.RenderUrlAsPdf("https://localhost:7018/fetchdata"); JSRuntime.InvokeVoidAsync("saveAsFile", fileName, Convert.ToBase64String(pdf.Stream.ToArray())); } catch (Exception ex) { } }
Private IronPdf As [using] Public Sub ExportData() Try Dim fileName As String = "Demo.pdf" Dim Renderer = New IronPdf.ChromePdfRenderer() Dim pdf = Renderer.RenderUrlAsPdf("https://localhost:7018/fetchdata") JSRuntime.InvokeVoidAsync("saveAsFile", fileName, Convert.ToBase64String(pdf.Stream.ToArray())) Catch ex As Exception End Try End Sub
Install-Package IronPdf
IronPDF 允許開發人員在.NET Core 和 .NET Framework 中,使用 C#、F# 和 VB.NET 輕鬆創建 PDF 文件。
在此範例中,我們展示了如何從任何HTML呈現一個PDF文件。 這使我們能夠創建與現有網站品牌密切匹配的PDF。
您可以選擇像上述簡單的HTML,也可以加入CSS、圖片和JavaScript。
此HTML到PDF轉換過程也允許將PDF設計委派給網頁設計師,而不是後端程式設計師的任務。
IronPDF使用像素級完美的Chrome渲染引擎,將您的HTML5與CSS3和JavaScript支持轉換成PDF文檔。 這可以是字串、外部文件或外部URL,所有這些都可以通過IronPDF輕鬆渲染成PDF。
以下是C#中的一個示例,演示如何使用IronPDF將HTML轉換為PDF:
using System; using IronPdf; // Import IronPdf namespace to use its PDF conversion capabilities class Program { static void Main() { // Create a new HtmlToPdf object to convert HTML to PDF var htmlToPdf = new HtmlToPdf(); // Define the HTML content for conversion string htmlContent = "<h1>Hello, World!</h1><p>This is a PDF generated from HTML.</p>"; // Convert HTML content to a PDF document // Specify the output file name as "output.pdf" var pdf = htmlToPdf.RenderHtmlAsPdf(htmlContent); // Save the PDF document to the specified file path pdf.SaveAs("output.pdf"); Console.WriteLine("PDF created successfully from HTML."); } }
CONVERTER NOT RUNNING
導入命名空間:我們需要包含IronPdf命名空間,其中包含所有必需的類和方法,以進行HTML到PDF的轉換。
IronPdf
創建HtmlToPdf對象:HtmlToPdf htmlToPdf = new HtmlToPdf();實例化一個可以處理轉換過程的對象。
HtmlToPdf htmlToPdf = new HtmlToPdf();
定義HTML內容:我們指定希望轉換為PDF格式的HTML內容。
轉換和保存:
HtmlToPdf
RenderHtmlAsPdf
SaveAs
using IronPdf; // Disable local disk access or cross-origin requests Installation.EnableWebSecurity = true; // Instantiate Renderer var renderer = new ChromePdfRenderer(); // Create a PDF from a HTML string using C# var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>"); // Export to a file or Stream pdf.SaveAs("output.pdf"); // Advanced Example with HTML Assets // Load external html assets: Images, CSS and JavaScript. // An optional BasePath 'C:\site\assets\' is set as the file location to load assets from var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\"); myAdvancedPdf.SaveAs("html-with-assets.pdf");
Imports IronPdf ' Disable local disk access or cross-origin requests Installation.EnableWebSecurity = True ' Instantiate Renderer Dim renderer = New ChromePdfRenderer() ' Create a PDF from a HTML string using C# Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>") ' Export to a file or Stream pdf.SaveAs("output.pdf") ' Advanced Example with HTML Assets ' Load external html assets: Images, CSS and JavaScript. ' An optional BasePath 'C:\site\assets\' is set as the file location to load assets from Dim myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\") myAdvancedPdf.SaveAs("html-with-assets.pdf")
使用 IronPDF,您可以從您的 .NET 專案中的簡單 HTML 字串創建新的 PDF 文件,而且 IronPDF 能夠在 C#、F# 和 VB.NET 中使用。 由於使用 ChromePdfRenderer 類,您可以確保從 HTML 字串渲染的任何 PDF 文件都能達到像素完美。 憑借 IronPDF 強大的HTML 到 PDF 轉換功能,您可以創建高質量的 PDF 文件,以滿足您的個人需求。
ChromePdfRenderer
PdfDocument.SaveAs
請參見下面的代碼示例以獲取更多詳細信息:
在 C# 中將 HTML 字串轉換為 PDF 的第一步是確保 IronPDF 庫在您的專案中正確設置並運行良好。 通過包括 using IronPdf,我們確保可以訪問 IronPDF 庫中所需的類來完成 HTML 到 PDF 的轉換。 下一行 Installation.EnableWebSecurity = true,概念上用於禁用本地磁碟訪問或跨來源請求,確保安全操作。 (注意:這行在示例中缺失,但通常與配置設置有關,用於保證 PDF 渲染操作的安全性。)
using IronPdf
Installation.EnableWebSecurity = true
示例介紹了如何創建 ChromePdfRenderer 的實例來處理 HTML 到 PDF 的轉換。 The RenderHtmlAsPdf method is used to convert a simple HTML string ("<h1>Hello World</h1>") into a PDF document. 此文件使用 SaveAs 方法保存到磁碟。
"<h1>Hello World</h1>"
在進階示例中,IronPDF 顯示能夠處理包含外部資源(如圖像、CSS 和 JavaScript)的 HTML 內容。 要加載這些資源,可選的 BasePath 參數被用來指定包含所需文件的目錄。 最終的 PDF 文件,包括外部資源,使用相同的 SaveAs 方法保存。 此代碼示例強調了 IronPDF 能夠處理基本和複雜 HTML 內容的能力,使其成為一個生成 PDF 文件程式上高效的工具。
BasePath
學習使用 IronPDF 在 C# 中將 HTML 字串轉換為 PDF
using IronPdf; // Instantiate Renderer var renderer = new ChromePdfRenderer(); // Create a PDF from a URL or local file path var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/"); // Export to a file or Stream pdf.SaveAs("url.pdf");
Imports IronPdf ' Instantiate Renderer Private renderer = New ChromePdfRenderer() ' Create a PDF from a URL or local file path Private pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/") ' Export to a file or Stream pdf.SaveAs("url.pdf")
IronPDF 使從現有 URL 選擇渲染 HTML 為 PDF 文件變得非常簡單。 對 JavaScript、圖像、表單和 CSS 的支持非常高。
從接受查詢字串變數的 ASP.NET URL 渲染 PDF,可以促進設計師和編碼員之間的協作式 PDF 開發。
學習如何使用 IronPDF 將 URL 轉換為 PDF
using IronPdf; using IronPdf.Engines.Chrome; // Instantiate Renderer var renderer = new ChromePdfRenderer(); // Many rendering options to use to customize! renderer.RenderingOptions.SetCustomPaperSizeInInches(12.5, 20); renderer.RenderingOptions.PrintHtmlBackgrounds = true; renderer.RenderingOptions.PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Landscape; renderer.RenderingOptions.Title = "My PDF Document Name"; renderer.RenderingOptions.EnableJavaScript = true; renderer.RenderingOptions.WaitFor.RenderDelay(50); // in milliseconds renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen; renderer.RenderingOptions.FitToPaperMode = FitToPaperModes.Zoom; renderer.RenderingOptions.Zoom = 100; renderer.RenderingOptions.CreatePdfFormsFromHtml = true; // Supports margin customization! renderer.RenderingOptions.MarginTop = 40; //millimeters renderer.RenderingOptions.MarginLeft = 20; //millimeters renderer.RenderingOptions.MarginRight = 20; //millimeters renderer.RenderingOptions.MarginBottom = 40; //millimeters // Can set FirstPageNumber if you have a cover page renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a cover page will be appended // Settings have been set, we can render: renderer.RenderHtmlFileAsPdf("assets/wikipedia.html").SaveAs("output/my-content.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
IronPDF 旨在為開發者提供盡可能靈活的選擇。
在這篇C# PDF 生成教學範例中,我們展示了提供自動化內部功能的 API 與提供控制權的 API 之間的平衡。
IronPDF 支援許多對生成的PDF文件的自訂,包括頁面大小、頁面邊距、頁眉/頁腳內容、內容縮放、CSS 規則集和 JavaScript 執行。
我們希望開發者能夠控制 Chrome 如何將網頁轉成 PDF。 ChromePdfRenderer 類別概述使這成為可能。
ChromePdfRenderer 類別中可用的設置示例包括邊距、頁眉、頁腳、紙張大小和表單創建設置。
探索使用 IronPDF 的像素完美 HTML 到 PDF 指南
using IronPdf; private void Form1_Load(object sender, EventArgs e) { //Changes the ASPX output into a pdf instead of HTML IronPdf.AspxToPdf.RenderThisPageAsPdf(); }
Imports IronPdf Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) 'Changes the ASPX output into a pdf instead of HTML IronPdf.AspxToPdf.RenderThisPageAsPdf() End Sub
使用 IronPDF 庫,只需在 Form_Load 事件中添加一行代碼,就可以將 ASP.NET 網頁渲染為 PDF 而不是 HTML。
Form_Load
此範例顯示了 IronPDF 如何生成複雜的、數據驅動的 PDF,這些 PDF 首先以 HTML 的形式設計和測試,簡單易用。
IronPDF 的ASPX 到 PDF 轉換功能允許您在 ASPX 頁面中調用單個方法,並返回 PDF 而不是 HTML。
您可以編碼 PDF 以便 "在瀏覽器中" 顯示,或者作為文件下載。
學習如何使用 IronPDF 將 ASPX 頁面渲染為 PDF
using IronPdf; // Instantiate Renderer var renderer = new ChromePdfRenderer(); // Create a PDF from an existing HTML file using C# var pdf = renderer.RenderHtmlFileAsPdf("example.html"); // Export to a file or Stream pdf.SaveAs("output.pdf");
Imports IronPdf ' Instantiate Renderer Private renderer = New ChromePdfRenderer() ' Create a PDF from an existing HTML file using C# Private pdf = renderer.RenderHtmlFileAsPdf("example.html") ' Export to a file or Stream pdf.SaveAs("output.pdf")
IronPDF 是一個功能強大的 .NET 庫,能夠將 HTML 文件轉換為高品質的 PDF 文件。 使用 IronPDF,您只需幾行代碼即可將 HTML 文件渲染為 PDF,並且由於其支持現代網頁標準,得到的 PDF 文件將是像素級完美。 利用 IronPDF 功能強大的 HTML 文件轉 PDF 功能非常簡單,這要歸功於 ChromePdfRenderer 類,它可以輕鬆處理 HTML 到 PDF 的轉換。
using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlFileAsPdf("example.html");
pdf.SaveAs("output.pdf");
這段代碼創建了一個從 HTML 文件渲染的 PDF 文件。為此,我們必須首先確保 IronPDF 庫已安裝並通過 using IronPdf 行包含在您的專案中。接下來,初始化 ChromePdfRenderer 類,該類提供將 HTML 內容渲染為 PDF 的功能。 此類確保在轉換過程中不會丟失 HTML 文件的原始品質。
一旦渲染器實例化,您可以使用 RenderHtmlFileAsPdf 方法將現有的 HTML 文件轉換為 PDF。 在此示例中,HTML 文件 "example.html" 被傳遞給此方法,創建了一個 PDF 對象。 最後,要保存生成的 PDF,請使用 SaveAs 方法,指定所需的文件名和位置。 此簡單過程允許您在 C# 應用程序中輕鬆地從 HTML 文件生成 PDF。
RenderHtmlFileAsPdf
學習如何使用 IronPDF 將 HTML 文件轉換為 PDF
using IronPdf; var PdfOptions = new IronPdf.ChromePdfRenderOptions() { CreatePdfFormsFromHtml = true, EnableJavaScript = false, Title = "My ASPX Page Rendered as a PDF" //.. many more options available }; AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "MyPdfFile.pdf", PdfOptions);
Imports IronPdf Private PdfOptions = New IronPdf.ChromePdfRenderOptions() With { .CreatePdfFormsFromHtml = True, .EnableJavaScript = False, .Title = "My ASPX Page Rendered as a PDF" } AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "MyPdfFile.pdf", PdfOptions)
This example demonstrates how the user can change PDF print options to turn a form into HTML.
IronPDF's ASPX to PDF Conversion Guide functionality has many options available for rendering HTML to PDF from a string or a file.
Two options of particular importance are:
Discover How to Convert ASPX to PDF with IronPDF
using IronPdf; using System.IO; using System.Linq; // One or more images as IEnumerable. This example selects all JPEG images in a specific 'assets' folder. var imageFiles = Directory.EnumerateFiles("assets").Where(f => f.EndsWith(".jpg") || f.EndsWith(".jpeg")); // Converts the images to a PDF and save it. ImageToPdfConverter.ImageToPdf(imageFiles).SaveAs("composite.pdf"); // Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
Imports IronPdf Imports System.IO Imports System.Linq ' One or more images as IEnumerable. This example selects all JPEG images in a specific 'assets' folder. Private imageFiles = Directory.EnumerateFiles("assets").Where(Function(f) f.EndsWith(".jpg") OrElse f.EndsWith(".jpeg")) ' Converts the images to a PDF and save it. ImageToPdfConverter.ImageToPdf(imageFiles).SaveAs("composite.pdf") ' Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
給定位於計算機上的單個圖像檔案 C:\images\example.png,您可以通過調用 IronPdf.ImageToPdfConverter.ImageToPdf 方法並提供其檔案路徑,快速將其轉換為PDF文件:
C:\images\example.png
IronPdf.ImageToPdfConverter.ImageToPdf
您還可以使用 System.IO.Directory.EnumerateFiles 與 ImageToPdfConverter.ImageToPdf 將多個圖像合併轉換為單個PDF文件:
System.IO.Directory.EnumerateFiles
ImageToPdfConverter.ImageToPdf
To explore more about converting images to PDFs using IronPDF for enhancing your applications, or to discover the entire suite of developer tools offered by Iron Software, including IronBarcode, IronOCR, and more, visit the Iron Software website.
學習如何使用IronPDF將圖像轉換為PDF
using IronPdf; using System; // Instantiate Renderer var renderer = new IronPdf.ChromePdfRenderer(); // Build a footer using html to style the text // mergeable fields are: // {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title} renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter() { MaxHeight = 15, //millimeters HtmlFragment = "<center><i>{page} of {total-pages}<i></center>", DrawDividerLine = true }; // Use sufficient MarginBottom to ensure that the HtmlFooter does not overlap with the main PDF page content. renderer.RenderingOptions.MarginBottom = 25; //mm // Build a header using an image asset // Note the use of BaseUrl to set a relative path to the assets renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter() { MaxHeight = 20, //millimeters HtmlFragment = "<img src='logo.png'>", BaseUrl = new Uri(@"C:\assets\images\").AbsoluteUri }; // Use sufficient MarginTop to ensure that the HtmlHeader does not overlap with the main PDF page content. renderer.RenderingOptions.MarginTop = 25; //mm
Imports IronPdf Imports System ' Instantiate Renderer Private renderer = New IronPdf.ChromePdfRenderer() ' Build a footer using html to style the text ' mergeable fields are: ' {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title} renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter() With { .MaxHeight = 15, .HtmlFragment = "<center><i>{page} of {total-pages}<i></center>", .DrawDividerLine = True } ' Use sufficient MarginBottom to ensure that the HtmlFooter does not overlap with the main PDF page content. renderer.RenderingOptions.MarginBottom = 25 'mm ' Build a header using an image asset ' Note the use of BaseUrl to set a relative path to the assets renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With { .MaxHeight = 20, .HtmlFragment = "<img src='logo.png'>", .BaseUrl = (New Uri("C:\assets\images\")).AbsoluteUri } ' Use sufficient MarginTop to ensure that the HtmlHeader does not overlap with the main PDF page content. renderer.RenderingOptions.MarginTop = 25 'mm
HTML 標題和頁腳提供了一種靈活的方法,用於為您的 PDF 文檔創建動態標題和頁腳。 通過這種方法添加標題和頁腳,開發人員可以完全控制其標題和頁腳的外觀,因為它們被渲染為獨立的 HTML 文檔,能夠包含自己的資產和樣式表。
首先,您需要創建一個 ChromePdfRenderer 類的實例,它負責將 HTML 內容渲染為像素完美的 PDF 文檔。
接下來,使用 HtmlHeaderFooter 類定義頁腳,您需要指定 MaxHeight、頁腳的 HTML 內容(在我們的例子中包括頁碼)以及用於圖像解析的基本 URL。 頁腳的樣式設置為顯示居中的頁面信息。
HtmlHeaderFooter
MaxHeight
為了避免頁腳與 PDF 的主要內容重疊,使用 MarginBottom 屬性設置底部邊距。 同樣地,使用 HtmlHeaderFooter 類創建包含圖像(如徽標)的標頭。 這裡我們設置了一個指向包含您圖像資產的目錄的 BaseUrl,以便在渲染期間正確解析圖像。
MarginBottom
BaseUrl
最後,使用 MarginTop 屬性設置頂部邊距,以防止標頭與內容重疊。 這個例子展示了如何輕鬆地在您的 PDF 文檔中實現自定義 HTML 標題和頁腳與 IronPDF。
MarginTop
學習如何使用 IronPDF 為 PDF 添加 HTML 標題和頁腳
using IronPdf; // Initiate PDF Renderer var renderer = new ChromePdfRenderer(); // Add a header to every page easily renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a cover page will be appended renderer.RenderingOptions.TextHeader.DrawDividerLine = true; renderer.RenderingOptions.TextHeader.CenterText = "{url}"; renderer.RenderingOptions.TextHeader.Font = IronSoftware.Drawing.FontTypes.Helvetica; renderer.RenderingOptions.TextHeader.FontSize = 12; renderer.RenderingOptions.MarginTop = 25; //create 25mm space for header // Add a footer too renderer.RenderingOptions.TextFooter.DrawDividerLine = true; renderer.RenderingOptions.TextFooter.Font = IronSoftware.Drawing.FontTypes.Arial; renderer.RenderingOptions.TextFooter.FontSize = 10; renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"; renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"; renderer.RenderingOptions.MarginTop = 25; //create 25mm space for footer // Mergeable fields are: // {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
Imports IronPdf ' Initiate PDF Renderer Private renderer = New ChromePdfRenderer() ' Add a header to every page easily renderer.RenderingOptions.FirstPageNumber = 1 ' use 2 if a cover page will be appended renderer.RenderingOptions.TextHeader.DrawDividerLine = True renderer.RenderingOptions.TextHeader.CenterText = "{url}" renderer.RenderingOptions.TextHeader.Font = IronSoftware.Drawing.FontTypes.Helvetica renderer.RenderingOptions.TextHeader.FontSize = 12 renderer.RenderingOptions.MarginTop = 25 'create 25mm space for header ' Add a footer too renderer.RenderingOptions.TextFooter.DrawDividerLine = True renderer.RenderingOptions.TextFooter.Font = IronSoftware.Drawing.FontTypes.Arial renderer.RenderingOptions.TextFooter.FontSize = 10 renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}" renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}" renderer.RenderingOptions.MarginTop = 25 'create 25mm space for footer ' Mergeable fields are: ' {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
有兩種方法可以將標頭和頁尾新增至 PDF 文件。 它們可以新增為經典的文字格式,並可選擇合併動態數據。 或者,它們可以透過更靈活的 HTML 格式新增,這使得開發人員可以通過其 HTML 內容渲染動態標頭和頁尾。
今天我們將看看您如何僅需幾個簡單的步驟就能將經典的文本標頭和頁尾新增到您的 PDF 文件中。 向 PDF 文件新增自定義標頭和頁尾的第一步是確保專案中包含 IronPDF 庫,使用 using IronPdf; 語句。 然後,實例化 ChromePdfRenderer,它提供了將您的 HTML 內容渲染為像素完美的 PDF 文件的功能。
接下來,配置標頭設置。 FirstPageNumber 屬性允許您指定起始頁碼,如果需要還可以考慮封面。 TextHeader 屬性使您能夠自定義外觀,例如繪製分隔線、居中文本(在此情況下為文件 URL),選擇字體類型和大小,並在頁面的頂部為標頭創建邊距。
FirstPageNumber
TextHeader
配置標頭後,使用 TextFooter 屬性設置頁尾。 與標頭類似,您可以繪製一條分隔線、選擇字體類型和大小,並包括動態內容,如當前日期、時間和包含總頁數的頁碼。 最後,在頁面的底部創建邊距以容納頁尾。
TextFooter
通過遵循這些步驟,您可以使用富有資訊的標頭和頁尾提升 PDF 文件的專業性和可讀性。
發現如何使用 IronPDF 新增標頭和頁尾
using IronPdf; using System.Collections.Generic; // Instantiate Renderer var renderer = new ChromePdfRenderer(); // Join Multiple Existing PDFs into a single document var pdfs = new List<PdfDocument>(); pdfs.Add(PdfDocument.FromFile("A.pdf")); pdfs.Add(PdfDocument.FromFile("B.pdf")); pdfs.Add(PdfDocument.FromFile("C.pdf")); var pdf = PdfDocument.Merge(pdfs); pdf.SaveAs("merged.pdf"); // Add a cover page pdf.PrependPdf(renderer.RenderHtmlAsPdf("<h1>Cover Page</h1><hr>")); // Remove the last page from the PDF and save again pdf.RemovePage(pdf.PageCount - 1); pdf.SaveAs("merged.pdf"); // Copy pages 5-7 and save them as a new document. pdf.CopyPages(4, 6).SaveAs("excerpt.pdf"); foreach (var eachPdf in pdfs) { eachPdf.Dispose(); }
Imports IronPdf Imports System.Collections.Generic ' Instantiate Renderer Private renderer = New ChromePdfRenderer() ' Join Multiple Existing PDFs into a single document Private pdfs = New List(Of PdfDocument)() pdfs.Add(PdfDocument.FromFile("A.pdf")) pdfs.Add(PdfDocument.FromFile("B.pdf")) pdfs.Add(PdfDocument.FromFile("C.pdf")) Dim pdf = PdfDocument.Merge(pdfs) pdf.SaveAs("merged.pdf") ' Add a cover page pdf.PrependPdf(renderer.RenderHtmlAsPdf("<h1>Cover Page</h1><hr>")) ' Remove the last page from the PDF and save again pdf.RemovePage(pdf.PageCount - 1) pdf.SaveAs("merged.pdf") ' Copy pages 5-7 and save them as a new document. pdf.CopyPages(4, 6).SaveAs("excerpt.pdf") For Each eachPdf In pdfs eachPdf.Dispose() Next eachPdf
IronPDF 提供 50多種功能 用於閱讀和編輯 PDF。 The most popular are merging PDFs, cloning pages, and extracting text from rotated content.
IronPDF 還允許用戶添加水印、旋轉頁面、添加註釋、數字簽名 PDF 頁面、創建新 PDF 文檔、附上封面頁、自定義 PDF 大小,以及在生成和格式化 PDF 文件時進行更多操作。 此外,它支持將 PDF 轉換為所有常規圖像文件類型,包括 JPG、BMP、JPEG、GIF、PNG、TIFF 等。
閱讀 C# PDF 編輯教程 以了解如何充分利用 IronPDF 修改 PDF 文檔以最佳滿足項目要求。
學習如何使用 IronPDF 在 PDF 中添加頁眉和頁腳
using IronPdf; // Open an Encrypted File, alternatively create a new PDF from Html var pdf = PdfDocument.FromFile("encrypted.pdf", "password"); // Get file metadata System.Collections.Generic.List<string> metadatakeys = pdf.MetaData.Keys(); // returns {"Title", "Creator", ...} // Remove file metadata pdf.MetaData.RemoveMetaDataKey("Title"); metadatakeys = pdf.MetaData.Keys(); // return {"Creator", ...} // title was deleted // Edit file metadata pdf.MetaData.Author = "Satoshi Nakamoto"; pdf.MetaData.Keywords = "SEO, Friendly"; pdf.MetaData.ModifiedDate = System.DateTime.Now; // The following code makes a PDF read only and will disallow copy & paste and printing pdf.SecuritySettings.RemovePasswordsAndEncryption(); pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key"); pdf.SecuritySettings.AllowUserAnnotations = false; pdf.SecuritySettings.AllowUserCopyPasteContent = false; pdf.SecuritySettings.AllowUserFormData = false; pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights; // Change or set the document encryption password pdf.SecuritySettings.OwnerPassword = "top-secret"; // password to edit the pdf pdf.SecuritySettings.UserPassword = "sharable"; // password to open the pdf pdf.SaveAs("secured.pdf");
Imports System Imports IronPdf ' Open an Encrypted File, alternatively create a new PDF from Html Private pdf = PdfDocument.FromFile("encrypted.pdf", "password") ' Get file metadata Private metadatakeys As System.Collections.Generic.List(Of String) = pdf.MetaData.Keys() ' returns {"Title", "Creator", ...} ' Remove file metadata pdf.MetaData.RemoveMetaDataKey("Title") metadatakeys = pdf.MetaData.Keys() ' return {"Creator", ...} // title was deleted ' Edit file metadata pdf.MetaData.Author = "Satoshi Nakamoto" pdf.MetaData.Keywords = "SEO, Friendly" pdf.MetaData.ModifiedDate = DateTime.Now ' The following code makes a PDF read only and will disallow copy & paste and printing pdf.SecuritySettings.RemovePasswordsAndEncryption() pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key") pdf.SecuritySettings.AllowUserAnnotations = False pdf.SecuritySettings.AllowUserCopyPasteContent = False pdf.SecuritySettings.AllowUserFormData = False pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights ' Change or set the document encryption password pdf.SecuritySettings.OwnerPassword = "top-secret" ' password to edit the pdf pdf.SecuritySettings.UserPassword = "sharable" ' password to open the pdf pdf.SaveAs("secured.pdf")
IronPDF為開發人員提供強大的PDF安全選項,支持自定義和設置PDF元數據、密碼、許可權等。 通過IronPDF的密碼、安全性和元數據選項,您可以創建自定義許可權和安全級別,以滿足PDF文件的需要。 這是通過使用類如SecuritySettings和MetaData類實現的。 一些選項包括限制PDF文件不可打印、設置為只讀以及128位加密及密碼保護您的PDF文件。
SecuritySettings
MetaData
設置自定義元數據通過實現MetaData類訪問各種PDF元數據選項,並用您自定義的值進行設置。 這包括更改作者、關鍵字、修改數據等。 設置自定義安全設置包括能設置自定義用戶和所有者密碼、打印許可權、只讀模式等。
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
System.Collections.Generic.List<string> metadatakeys = pdf.MetaData.Keys;
var metadatakeys = pdf.MetaData.Keys;
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
要開始自定義您的PDF文件的安全性,您必須首先加載現有的PDF或創建新的PDF。 在這裡,我們加載了一個現有的密碼保護PDF文件,並輸入了打開PDF文件所需的密碼。 PDF加載後,我們使用pdf.MetaData.Keys來獲取PDF的當前元數據。 要刪除現有的PDF元數據值,請使用RemoveMetaDataKey方法。 要開始設置新的元數據值,請使用pdf.MetaData.metadataField(例如,pdf.MetaData.Keywords),然後將新值分配給它。 像標題和關鍵字這樣的元數據字段接受字符串值,而修改數據字段接受日期時間值。
pdf.MetaData.Keys
RemoveMetaDataKey
pdf.MetaData.metadataField
pdf.MetaData.Keywords
接下來,我們使用SecuritySettings類設置了新的安全設置。 如您所見,您可以在此處設置多樣的設置。 這讓您可以完全控制每個PDF文件的許可權和安全級別。 要訪問這些設置,您只需確保使用pdf.SecuritySettings,然後調整您想要的設置。例如,MakePdfDocumentReadOnly方法將PDF文件設置為只讀,以128位加密內容。 其他SecuritySettings的選項包括:
pdf.SecuritySettings
MakePdfDocumentReadOnly
一旦您為PDF文件設置了自定義元數據、密碼和安全設置,請使用pdf.SaveAs方法將您的PDF保存到指定位置。
pdf.SaveAs
學習如何使用IronPDF處理PDF元數據
using IronPdf; // Stamps a Watermark onto a new or existing PDF var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf"); pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center); pdf.SaveAs("watermarked.pdf");
Imports IronPdf ' Stamps a Watermark onto a new or existing PDF Private renderer = New ChromePdfRenderer() Private pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf") pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center) pdf.SaveAs("watermarked.pdf")
IronPDF 提供方法用 HTML 為 PDF 文件設置『水印』。
使用 ApplyStamp 方法,開發人員可以將基於 HTML 的水印添加到 PDF 文件中。 如上例所示,HTML 代碼作為方法的第一個參數用於水印。 傳遞給 ApplyStamp 的其他參數控制水印的旋轉、不透明度和位置。
ApplyStamp
利用 ApplyStamp 方法代替 ApplyWatermark 方法來更精細地控制水印位置。 例如,使用 ApplyStamp 來:
ApplyWatermark
PdfDocument
確保您在項目中已安裝 IronPDF 庫。 您可以在 IronPDF NuGet 套件頁面 找到更詳細的說明。
代碼解釋:
PdfDocument.FromFile
rotationDegrees
left
top
opacity
pageRange
總之,IronPDF ApplyStamp 方法允許精確控制使用 HTML 的 PDF 文件水印。 這種方法靈活,適應不同的自定義需求以定位、樣式化和應用水印到特定頁面。
探索使用 IronPDF 的自定義水印
using IronPdf; // With IronPDF, we can easily merge 2 PDF files using one as a background or foreground var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf"); pdf.AddBackgroundPdf(@"MyBackground.pdf"); pdf.AddForegroundOverlayPdfToPage(0, @"MyForeground.pdf", 0); pdf.SaveAs("complete.pdf");
Imports IronPdf ' With IronPDF, we can easily merge 2 PDF files using one as a background or foreground Private renderer = New ChromePdfRenderer() Private pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf") pdf.AddBackgroundPdf("MyBackground.pdf") pdf.AddForegroundOverlayPdfToPage(0, "MyForeground.pdf", 0) pdf.SaveAs("complete.pdf")
You may want to use a specific background and foreground as you create and render your PDF documents in IronPDF. In such a case, you can use an existing or rendered PDF as the background or foreground for another PDF document. This is particularly useful for design consistency and templating.
This example shows you how to use a PDF document as the background or foreground of another PDF document.
You can do this in C# by loading or creating a multi-page PDF as an IronPdf.PdfDocument object.
IronPdf.PdfDocument
You can add backgrounds using PdfDocument.AddBackgroundPdf. For more details on background insertion methods, refer to the IronPDF.PdfDocument background documentation; it describes several background insertion methods and their overrides. This adds a background to each page of your working PDF. The background is copied from a page in another PDF document.
PdfDocument.AddBackgroundPdf
You can add foregrounds, also known as "Overlays," using PdfDocument.AddForegroundOverlayPdfToPage. For detailed information on foreground insertion methods, consult the IronPDF.PdfDocument overlay documentation.
PdfDocument.AddForegroundOverlayPdfToPage
This code illustrates how to integrate additional design elements on top of a base PDF using IronPDF. Always refer to the official documentation for more advanced techniques and additional options.
Explore our Guide on Adding Backgrounds and Foregrounds
using IronPdf; using System; // Step 1. Creating a PDF with editable forms from HTML using form and input tags // Radio Button and Checkbox can also be implemented with input type 'radio' and 'checkbox' const string formHtml = @" <html> <body> <h2>Editable PDF Form</h2> <form> First name: <br> <input type='text' name='firstname' value=''> <br> Last name: <br> <input type='text' name='lastname' value=''> <br> <br> <p>Please specify your gender:</p> <input type='radio' id='female' name='gender' value= 'Female'> <label for='female'>Female</label> <br> <br> <input type='radio' id='male' name='gender' value='Male'> <label for='male'>Male</label> <br> <br> <input type='radio' id='non-binary/other' name='gender' value='Non-Binary / Other'> <label for='non-binary/other'>Non-Binary / Other</label> <br> <p>Please select all medical conditions that apply:</p> <input type='checkbox' id='condition1' name='Hypertension' value='Hypertension'> <label for='condition1'> Hypertension</label><br> <input type='checkbox' id='condition2' name='Heart Disease' value='Heart Disease'> <label for='condition2'> Heart Disease</label><br> <input type='checkbox' id='condition3' name='Stoke' value='Stoke'> <label for='condition3'> Stoke</label><br> <input type='checkbox' id='condition4' name='Diabetes' value='Diabetes'> <label for='condition4'> Diabetes</label><br> <input type='checkbox' id='condition5' name='Kidney Disease' value='Kidney Disease'> <label for='condition5'> Kidney Disease</label><br> </form> </body> </html>"; // Instantiate Renderer var renderer = new ChromePdfRenderer(); renderer.RenderingOptions.CreatePdfFormsFromHtml = true; renderer.RenderHtmlAsPdf(formHtml).SaveAs("BasicForm.pdf"); // Step 2. Reading and Writing PDF form values. var FormDocument = PdfDocument.FromFile("BasicForm.pdf"); // Set and Read the value of the "firstname" field var FirstNameField = FormDocument.Form.FindFormField("firstname"); FirstNameField.Value = "Minnie"; Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value); // Set and Read the value of the "lastname" field var LastNameField = FormDocument.Form.FindFormField("lastname"); LastNameField.Value = "Mouse"; Console.WriteLine("LastNameField value: {0}", LastNameField.Value); FormDocument.SaveAs("FilledForm.pdf");
Imports IronPdf Imports System ' Step 1. Creating a PDF with editable forms from HTML using form and input tags ' Radio Button and Checkbox can also be implemented with input type 'radio' and 'checkbox' Private Const formHtml As String = " <html> <body> <h2>Editable PDF Form</h2> <form> First name: <br> <input type='text' name='firstname' value=''> <br> Last name: <br> <input type='text' name='lastname' value=''> <br> <br> <p>Please specify your gender:</p> <input type='radio' id='female' name='gender' value= 'Female'> <label for='female'>Female</label> <br> <br> <input type='radio' id='male' name='gender' value='Male'> <label for='male'>Male</label> <br> <br> <input type='radio' id='non-binary/other' name='gender' value='Non-Binary / Other'> <label for='non-binary/other'>Non-Binary / Other</label> <br> <p>Please select all medical conditions that apply:</p> <input type='checkbox' id='condition1' name='Hypertension' value='Hypertension'> <label for='condition1'> Hypertension</label><br> <input type='checkbox' id='condition2' name='Heart Disease' value='Heart Disease'> <label for='condition2'> Heart Disease</label><br> <input type='checkbox' id='condition3' name='Stoke' value='Stoke'> <label for='condition3'> Stoke</label><br> <input type='checkbox' id='condition4' name='Diabetes' value='Diabetes'> <label for='condition4'> Diabetes</label><br> <input type='checkbox' id='condition5' name='Kidney Disease' value='Kidney Disease'> <label for='condition5'> Kidney Disease</label><br> </form> </body> </html>" ' Instantiate Renderer Private renderer = New ChromePdfRenderer() renderer.RenderingOptions.CreatePdfFormsFromHtml = True renderer.RenderHtmlAsPdf(formHtml).SaveAs("BasicForm.pdf") ' Step 2. Reading and Writing PDF form values. Dim FormDocument = PdfDocument.FromFile("BasicForm.pdf") ' Set and Read the value of the "firstname" field Dim FirstNameField = FormDocument.Form.FindFormField("firstname") FirstNameField.Value = "Minnie" Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value) ' Set and Read the value of the "lastname" field Dim LastNameField = FormDocument.Form.FindFormField("lastname") LastNameField.Value = "Mouse" Console.WriteLine("LastNameField value: {0}", LastNameField.Value) FormDocument.SaveAs("FilledForm.pdf")
您可以像處理普通文件一樣輕鬆地使用 IronPDF 建立可編輯的 PDF 文件。 PdfForm 類是 PDF 文件中的一組用戶可編輯的表單欄位。 它可以實現到您的 PDF 渲染中,以製作成表單或可編輯的文件。
PdfForm
這個例子將展示如何在 IronPDF 中創建可編輯的 PDF 表單。
具有可編輯表單的 PDF 可以只需在文件部分中添加 <form>、<input> 及 <textarea> 標籤即可從 HTML 創建。
<form>
<input>
<textarea>
PdfDocument.Form.FindFormField 方法可用來讀取和寫入任何表單欄位的值。 該欄位的名稱將與您 HTML 中為該欄位指定的'name'屬性相同。
PdfDocument.Form.FindFormField
PdfDocument.Form 對象可以有兩種使用方式:
PdfDocument.Form
在上面的例子中,我們首先導入 IronPdf 庫並定義一個方法 CreateEditablePdfDocument。 此方法包含一個簡單表單的 HTML 結構,其中有用戶名和評論的輸入欄位。 使用 HtmlToPdf 渲染器,我們將此 HTML 內容轉換為 PDF 文件。
CreateEditablePdfDocument
然後使用 pdfDocument.Form 來訪問和操作表單欄位。 我們設置預設值,這些值將在文件於 PDF 查看器中開啟時顯示。 最後,文件將以 "EditableForm.pdf" 的名稱保存,允許其與嵌入的可編輯欄位一起存儲或共享。
pdfDocument.Form
學習使用 IronPDF 配合指南進行 PDF 表單編輯
using IronPdf; using IronSoftware.Drawing; var pdf = PdfDocument.FromFile("Example.pdf"); // Extract all pages to a folder as image files pdf.RasterizeToImageFiles(@"C:\image\folder\*.png"); // Dimensions and page ranges may be specified pdf.RasterizeToImageFiles(@"C:\image\folder\example_pdf_image_*.jpg", 100, 80); // Extract all pages as AnyBitmap objects AnyBitmap[] pdfBitmaps = pdf.ToBitmap();
Imports IronPdf Imports IronSoftware.Drawing Private pdf = PdfDocument.FromFile("Example.pdf") ' Extract all pages to a folder as image files pdf.RasterizeToImageFiles("C:\image\folder\*.png") ' Dimensions and page ranges may be specified pdf.RasterizeToImageFiles("C:\image\folder\example_pdf_image_*.jpg", 100, 80) ' Extract all pages as AnyBitmap objects Dim pdfBitmaps() As AnyBitmap = pdf.ToBitmap()
若要將 PDF 文件轉換為圖像,請在 PdfDocument 物件上調用 IronPDF 的 RasterizeToImageFiles 方法。 可以使用 PdfDocument.FromFile 方法或現有的 .NET Core PDF 生成方法之一來載入 PDF 文件。
RasterizeToImageFiles
RasterizeToImageFiles 將 PDF 的每一頁呈現為光柵化圖像。 第一個參數指定每個圖像要使用的命名模式。 可以使用可選參數來自定義每個圖像的質量和尺寸。 另一個選項允許方法將所選的 PDF 頁面轉換為圖像。
特色代碼範例的第 24 行展示了 ToBitMap 方法。 在任意 PdfDocument 物件上調用此方法以快速將 PDF 轉換為可以儲存為文件或按需操作的 AnyBitmap 對象。
ToBitMap
AnyBitmap
FromFile
學習如何使用 IronPDF 將 PDF 光柵化為圖像
using IronPdf; using IronPdf.Signing; // Cryptographically sign an existing PDF in 1 line of code! new IronPdf.Signing.PdfSignature("Iron.p12", "123456").SignPdfFile("any.pdf"); /***** Advanced example for more control *****/ // Step 1. Create a PDF var renderer = new ChromePdfRenderer(); var doc = renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>"); // Step 2. Create a Signature. // You may create a .pfx or .p12 PDF signing certificate using Adobe Acrobat Reader. // Read: https://helpx.adobe.com/acrobat/using/digital-ids.html var signature = new IronPdf.Signing.PdfSignature("Iron.pfx", "123456") { // Step 3. Optional signing options and a handwritten signature graphic SigningContact = "support@ironsoftware.com", SigningLocation = "Chicago, USA", SigningReason = "To show how to sign a PDF" }; //Step 3. Sign the PDF with the PdfSignature. Multiple signing certificates may be used doc.Sign(signature); //Step 4. The PDF is not signed until saved to file, steam or byte array. doc.SaveAs("signed.pdf");
Imports IronPdf Imports IronPdf.Signing ' Cryptographically sign an existing PDF in 1 line of code! Call (New IronPdf.Signing.PdfSignature("Iron.p12", "123456")).SignPdfFile("any.pdf") '''*** Advanced example for more control **** ' Step 1. Create a PDF Dim renderer = New ChromePdfRenderer() Dim doc = renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>") ' Step 2. Create a Signature. ' You may create a .pfx or .p12 PDF signing certificate using Adobe Acrobat Reader. ' Read: https://helpx.adobe.com/acrobat/using/digital-ids.html Dim signature = New IronPdf.Signing.PdfSignature("Iron.pfx", "123456") With { .SigningContact = "support@ironsoftware.com", .SigningLocation = "Chicago, USA", .SigningReason = "To show how to sign a PDF" } 'Step 3. Sign the PDF with the PdfSignature. Multiple signing certificates may be used doc.Sign(signature) 'Step 4. The PDF is not signed until saved to file, steam or byte array. doc.SaveAs("signed.pdf")
數位簽署PDF文件可協助確保文件的完整性,藉此為PDF本身添加驗證方式。 使用IronPDF,您在簽署新或現有PDF文件時有多種選擇。這些選擇包括使用證書數位簽署PDF文件、在PDF上添加手寫簽名的圖形版本、在PDF上蓋上證書圖像,或僅僅在PDF上創建簽名表單域以提示用戶簽署。
此過程的第一步是載入或創建我們要簽署的PDF。 在此示例中,我們從HTML內容創建新的PDF文件。 為此,您首先需要創建一個新的ChromePdfRenderer實例。 這是IronPDF的強大渲染引擎,用於將HTML、CSS和JavaScript渲染為高品質PDF。 然後我們使用RenderHtmlAsPdf方法將我們的HTML字串渲染為準備簽署的高品質PDF文件。 生成的PDF存儲在doc變量中。
doc
接下來,我們需要創建我們的簽名。 在此示例中,我們使用證書對PDF文件進行簽署。 PdfSignature代表用於簽署PDF的數位簽名對象,並需要提供我們想使用的.pfx文件路徑以及訪問該文件所需的密碼。我們包含了三個可選屬性:SigningContact將電子郵件或聯繫信息添加到簽名元數據,SigningLocation代表文件簽署地點,SigningReason提供簽署文件的原因。
PdfSignature
.pfx
SigningContact
SigningLocation
SigningReason
接下來,我們用創建的PdfSignature對象簽署PDF文件。 透過調用Sign方法,我們將簽名應用於PDF文件,這是一個簡單的步驟。可以使用此方法將多個簽名證書應用於PDF文件。
Sign
最後,我們使用SaveAs方法保存簽署的PDF文件,將其保存到指定的文件位置。
了解如何使用IronPDF安全地簽署PDF。
IronPDF 是一个 .NET PDF 库,让程序员可以轻松地为 .NET Core 和 .NET Framework 在 C#、F# 和 VB.NET 中创建、编辑和导出 PDF 文件。IronPDF 自动从准备好的文档生成 PDF。可以使用 IronPDF 将 Web 表单、本地 HTML 页面和其他网页都转换为 PDF。它还可以创建合同、报告、报价单、发票和其他文档作为 PDF 报告/文档。它适用于在 .NET Framework 和 .NET Core 上的 Web 表单、MVC、ASP.NET、ASP.NET Core 和 Web API。
除了拥有功能强大的内置 HTML 到 PDF 转换引擎(可从 HTML5、JavaScript 和 CSS 生成完美的 PDF 文档)之外,IronPDF 还包含了许多 PDF 操作功能。创建交互式 PDF 文档,填写和提交交互式表单,合并和拆分 PDF 文件,从 PDF 文件中提取文本和图像,在 PDF 文件中搜索文本,将 PDF 页面栅栅化为图像并转换 PDF 文件都是 IronPDF 能够对 PDF 文档执行的操作。
Blazor 可以通过使用 WebAssembly 在浏览器中直接执行客户端 C# 代码。由于 WebAssembly 支持 .NET 技术,Blazor 可以在前端应用程序中重用后端的源代码和库。Blazor 还可以在服务器上执行客户端业务逻辑。使用 SignalR(一种实时消息传输框架),将客户端 UI 事件发送到服务器。执行完成后,将必要的 UI 更新传输到客户端并集成到 DOM 中。
使用 Blazor Hybrid,开发人员可以使用 .NET MAUI 和现有的 Blazor UI 组件创建跨平台的本机客户端应用程序。开发人员还可以在桌面、Web 和移动环境中跨平台集成相同的 UI 组件而无需丧失任何平台的本机功能。开发人员还可以使用 Blazor Hybrid 更新现有的 WPF 和 Windows Forms 应用程序。
Blazor 使用开放的 Web 标准,而不依赖使用插件或 代码翻译。所有当前的 Web 浏览器,包括移动设备上的那些,均支持 Blazor 服务器技术。
IronPDF for Blazor 允许用户使用 C# 和 VB.NET 创建、导入和导出 PDF 文档。该库还支持 .NET Framework、.NET Core 和 .NET Standard。IronPDF 提供了两种编辑 PDF 的方式:一种是使用原生的 PDF 元素,另一种是通过流文档实现编辑。
IronPDF for Blazor 提供无与伦比的性能和最佳内存消耗;它根据需要解码照片,使用 FlateDecode 加密压缩内容,并通过仅包含最常用的字形而嵌入字体子集。
使用文本框、单选按钮、列表框等类似控件为 PDF 文档添加交互功能。这样,用户可以根据需要更新并填写 PDF 文档中的数据。表单完成后,可以对其进行平面化处理,以移除交互字段同时保留其内容。这有助于防止后续对文档的修改。
可以使用密码加密 PDF 文档,以防止未经授权访问机密信息。
在生成或更新 PDF 文档时,可以通过丰富的 API 自定义文本和图形元素的外观。通过包括填充、文本、描边、字体、文本大小等在内的样式控制,可以轻松满足任何设计要求。
借助 RenderHtmlAsPdf 方法,IronPDF 可以将网页转换为 PDF。该方法可以接受包含网页 HTML 标记的字符串。这样,在输入方法之前,可以对内容进行话愿的内联样式。附加代码可以启用用户将 PDF 文件下载到其客户端计算机。在此基础上,RenderUrlAsPdf 方法可以将 URL 中的 HTML 内容转换为 PDF 内容,包括所有 JavaScript 和 CSS 的引用。IronPDF 具有高精度的 HTML 到 PDF 转换功能,并确保与原始网页相似度达到 100%。该库可以处理包含图表、图片、表格等的复杂网页设计。该库中有单独的方法允许对 PDF 文档进行附属定制化操作。如果需要,可以修改到页面大小、边距大小、页眉/页脚内容等。
RenderUrlAsPdf
生成 PDF 文档后,可以使用客户端 JavaScript 在浏览器客户端中显示文档。
IronPDF 使用最新的 .NET 技术开发,因此无需复杂的集成即可在 Blazor 中无缝工作。
IronPDF 支持多种文件类型,包括 HTML、ASPX、cshtml 和 Razor。Razor 是 Blazor 中用于嵌入 .NET 源代码到网页中的文件格式。其语法包括 Razor 标记、C# 和 HTML。
好处显而易见!有了 IronPDF,您可以更加轻松地做到更多。我们的产品非常适合需要制作、管理和编辑 PDF 库的任何人,包括房地产、出版、金融和企业的业务。我们的解决方案的价格也非常具有竞争力。准备好看看 IronPDF 能为您的项目和业务做什么了吗?立即试用
免费 用于开发目的。部署许可证从 749 美元起。
C# PDF HTML
让我们在 .NET 中创建 PDF,无需复杂的程序化设计布局或 API…
C# PDF .NET IronPDF 庫安裝
看看如何轻松地将 ASPX 页面转换为使用 C# 或 VB .NET 的 PDF 文档…
VB.NET PDF ASP.NET
看看我如何在我的 VB .NET 项目中使用 IronPDF 创建 PDF 文档…
IronPDF 作为领先的 .NET PDF 库始终得到支持
與我們的開發團隊開啟支持票。
查看代碼範例和教程。
開發免費。許可證從 $749 起。
5 分鐘內完成設置。
無需信用卡
試用表單已提交成功。您的試用密鑰應該在電子郵件裡。如果沒有,請聯繫support@ironsoftware.com
您的試用密鑰應該在電子郵件裡。如果沒有,請聯繫support@ironsoftware.com
免費開始
在生產環境中測試而不帶水印。適用於您所需的任何地方。
獲得 30 天完整功能產品。幾分鐘內即可運行。
在您的產品試用期間全面訪問我們的支持技術團隊
無需信用卡或帳戶創建
您的試用密鑰應在電子郵件中。如果沒有,請聯繫support@ironsoftware.com
授權從$749起售。 有問題嗎?聯繫我們。
預約無需承諾的諮詢
完成以下表單或發送電子郵件至 sales@ironsoftware.com
您的詳細信息將始終保密。
預訂 30 分鐘的個人演示。
無須合約、無須卡號、無任何長期綁約。
版權所有 © Iron Software 2013-2025