C# + VB.NET: Using HTML To Create a PDF Using HTML To Create a PDF
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")

<p>With IronPDF, you can create new PDF documents from simple HTML strings within your .NET project, and IronPDF is able to be used in C#, F#, and VB.NET. Thanks to the use of the <code>ChromePdfRenderer</code> class, you can be sure that any PDF documents you render from HTML string will come out <a href="/how-to/pixel-perfect-html-to-pdf/" target="__blank">pixel-perfect</a>. With IronPDF's powerful <a href="/tutorials/html-to-pdf/" target="__blank">HTML to PDF conversion</a> features, you create high-quality PDF files tailored to fit your personal needs. </p> <h2 id="anchor-the-4-steps-to-converting-html-string-to-pdf">The 4 Steps to Converting HTML String to PDF</h2> <ol> <li>Import the IronPDF library</li> <li>Initialize a new <code>ChromePdfRenderer</code> Object.</li> <li>Use the <code>ChromePdfRenderer.RenderHtmlAsPdf</code> method.</li> <li>Save the PDF using <code>PdfDocument.SaveAs</code>.</li> </ol> <p>See the code example below for more details:</p> <pre class='naked-code'><code class="language-cs">using IronPdf; var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("&lt;h1&gt;Hello World&lt;/h1&gt;"); var myAdvancedPdf = renderer.RenderHtmlAsPdf("&lt;img src='icons/iron.png'&gt;", @"C:\site\assets\"); pdf.SaveAs("output.pdf");</code></pre> <div class="code-content code-content-inner"> <div class="code_window" > <div class="language-selection__content-page-wrapper"> </div> <div class="code_window_content"> <div class="code-window__action-buttons-wrapper code-window__action-buttons-wrapper--content-page"> <button title="Click to copy" class=" code-window__action-button code-window__action-button--copy copy-clipboard " data-copy-text="Click to copy" data-copied-text="Copied to clipboard" data-clipboard-id="code-explorer" data-placement="bottom" > <i class="fa-kit fa-copy-example"></i> </button> <button title="Full Screen Mode" class=" code-window__action-button code-window__action-button--full-screen js-full-screen-code-example-modal " > <i class="fas fa-expand"></i> </button> <button title="Exit Full Screen" class=" code-window__action-button code-window__action-button--exit-full-screen js-exit-full-screen-code-example-modal " > <i class="fas fa-compress"></i> </button> </div> <pre class="prettyprint linenums lang-cs"><code>using IronPdf; var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("&lt;h1&gt;Hello World&lt;/h1&gt;"); var myAdvancedPdf = renderer.RenderHtmlAsPdf("&lt;img src='icons/iron.png'&gt;", @"C:\site\assets\"); pdf.SaveAs("output.pdf");</code></pre> <pre class="prettyprint linenums lang-vb"><code>Imports IronPdf Private renderer = New ChromePdfRenderer() Private pdf = renderer.RenderHtmlAsPdf(&quot;&lt;h1&gt;Hello World&lt;/h1&gt;&quot;) Private myAdvancedPdf = renderer.RenderHtmlAsPdf(&quot;&lt;img src='icons/iron.png'&gt;&quot;, &quot;C:\site\assets\&quot;) pdf.SaveAs(&quot;output.pdf&quot;)</code></pre> </div> <div class="code_window_bottom"> <span class="language_selection"> <span class="ls-span">VB &nbsp;</span> <span> <label class="switch"> <input type="checkbox" checked="checked"> <span class="slider round"></span> </label> </span> <span class="ls-span">C#</span> </span> </div> </div> </div> <p>The first step to converting HTML string to PDF in C# is ensuring that you have the IronPDF library properly set up and working within your project. By including using IronPdf, we are making sure we can access the classes needed from the IronPDF library to carry out HTML to PDF conversion. Once this is done, the next line, <code>Installation.EnableWebSecurity = true</code> is used to disable local disk access or cross-origin requests, ensuring secure operations. </p> <p>This next line creates a new ChromePdfRenderer instance, which will handle the conversion of HTML to PDF. In the basic example, the RenderHtmlAsPdf method is used to convert a simple HTML string <code>("&lt;h1&gt;Hello World&lt;/h1&gt;")</code> into a PDF document, which is saved to the disk using the <code>SaveAs</code> method. </p> <p>In the advanced method, we demonstrate how IronPDF can handle HTML content containing external assets such as images, CSS, and JavaScript. To load these assets, the optional BasePath parameter is used, which specifies the directory containing the required files. The resulting PDF, which includes the external assets, is saved using the same <code>SaveAs</code> method as seen in the basic example. This code example highlights IronPDF's ability to handle both basic and complex HTML content, making it an efficient tool for generating PDFs programmatically. </p> <p><a href="/how-to/html-string-to-pdf/" target="__blank">For more examples, check the How-to Guide on using IronPDF with C#.</a></p>

C# + VB.NET: Converting a URL to a PDF Converting a URL to a 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")

<p>IronPDF makes it very straightforward to render HTML from existing URLs as PDF documents. There is a very high level of support for JavaScript, images, forms, and CSS.</p> <p>Rendering PDFs from ASP.NET URLs that accept query string variables can facilitate smooth PDF development as a collaborative effort between designers and coders.</p> <hr /> <h2 id="anchor-steps-to-convert-url-to-pdf-in-c">Steps to Convert URL to PDF in C</h2> <ol> <li>Download the <a href="/" target="_blank" rel="nofollow noopener noreferrer">IronPDF URL to PDF Conversion Library</a></li> <li>Install the library with NuGet to test its features</li> <li>Render PDFs from ASP.NET URLs that accept query string variables using IronPDF</li> <li>Create a PDF document directly from a URL with IronPDF</li> <li>View and validate your PDF output document easily</li> </ol>

C# + VB.NET: PDF Generation Settings PDF Generation Settings
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

<p>IronPDF aims to be as flexible as possible for the developer.</p> <p>In this <a href="/blog/using-ironpdf/csharp-generate-pdf-tutorial/" target="_blank" rel="nofollow noopener noreferrer">C# PDF Generation Tutorial Example</a>, we show the balance between providing an API that automates internal functionality and providing one that gives you control.</p> <p>IronPDF supports many customizations for generated PDF files, including: page sizing, page margins, header/footer content, content scaling, CSS rulesets, and JavaScript execution.</p> <hr class="separator"> <p>We want developers to be able to control how Chrome turns a web page into a PDF. The <a href="/object-reference/api/IronPdf.ChromePdfRenderOptions.html" target="_blank" rel="nofollow noopener noreferrer"><code>ChromePdfRenderer</code> Class Overview</a> makes this possible.</p> <p>Examples of settings available on the <code>ChromePDFRenderOptions</code> class include settings for margins, headers, footers, paper size, and form creation.</p>

C# + VB.NET: HTML or Image File to PDF HTML or Image File to 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")

<p>IronPDF is a powerful .NET library capable of converting HTML files into high-quality PDF files. With IronPDF, you can render HTML files to PDF in just a couple of lines, and thanks to its support for modern web standards, the resulting PDF files will come out pixel-perfect. Leveraging IronPDF's powerful HTML file to PDF feature is easy thanks to its use of the <code>ChromePdfRenderer</code> class, which handles the conversion of HTML to PDF with ease. </p> <h2 id="anchor-steps-to-convert-html-files-to-pdf-with-ironpdf">Steps to Convert HTML Files to PDF with IronPDF</h2> <ul> <li>Install the C# IronPDF library to convert HTML to PDF</li> <li>using IronPdf;</li> <li>var renderer = new ChromePdfRenderer();</li> <li>var pdf = renderer.RenderHtmlFileAsPdf(&quot;example.html&quot;);</li> <li>pdf.SaveAs(&quot;output.pdf&quot;);</li> </ul> <p>This code creates a new PDF file that has been rendered from an HTML file. To do this, we must first ensure that the IronPDF library is installed and included within your project through the <code>using IronPdf</code> line. Next, initialize the ChromePdfRenderer class, which provides the functionality to render HTML content as a PDF, this class ensures that the original quality of the HTML file is not lost in the conversion process.</p> <p>Once the renderer is instantiated, you can convert an existing HTML file into a PDF using the <code>RenderHtmlAsPdf</code> method. In this example, the HTML file &quot;example.html&quot; is passed to the method, creating a PDF object. Finally, to save the generated PDF, use the <code>SaveAs</code> method, specifying the desired file name and location. This simple process allows you to easily generate PDFs from HTML files in your C# applications.</p> <p><a href="/how-to/html-file-to-pdf/" target="__blank">Click here to view the How-to Guide, including examples, sample code, and files &gt;</a></p>

C# + VB.NET: ASPX To PDF Settings ASPX To PDF Settings
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)

<p>This example demonstrates how the user can change PDF print options to turn form into HTML.</p> <p>IronPDF's <a href="/how-to/aspx-to-pdf/" target="_blank" rel="nofollow noopener noreferrer">ASPX to PDF Conversion Guide</a> functionality has many options available for rendering HTML to PDF from a string or a file.</p> <p>Two options of particular importance are:</p> <ul> <li>Allowing developers to specify if HTML forms should be rendered as interactive PDF forms during conversion.</li> <li>Allowing developers to specify if the PDF should be displayed &quot;in browser,&quot; or as a file download.</li> </ul>

C# + VB.NET: Image To PDF Image To PDF
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

<p>Construct a PDF from one or more image files using the <code>IronPdf.ImageToPdfConverter</code> class.</p> <h2 id="anchor-how-to-convert-an-image-to-a-pdf-in-c-num">How to Convert an Image to a PDF in C&num;</h2> <p>Given a single image located on a computer at <code>C:\images\example.png</code>, we can convert it quickly into a PDF document by calling the <code>IronPdf.ImageToPdfConverter.ImageToPdf</code> method with its file path:</p> <pre class='naked-code'><code class="language-cs">IronPdf.ImageToPdfConverter.ImageToPdf(@"C:\images\example.png").SaveAs("example.pdf");</code></pre> <div class="code-content code-content-inner"> <div class="code_window" > <div class="language-selection__content-page-wrapper"> </div> <div class="code_window_content"> <div class="code-window__action-buttons-wrapper code-window__action-buttons-wrapper--content-page"> <button title="Click to copy" class=" code-window__action-button code-window__action-button--copy copy-clipboard " data-copy-text="Click to copy" data-copied-text="Copied to clipboard" data-clipboard-id="code-explorer" data-placement="bottom" > <i class="fa-kit fa-copy-example"></i> </button> <button title="Full Screen Mode" class=" code-window__action-button code-window__action-button--full-screen js-full-screen-code-example-modal " > <i class="fas fa-expand"></i> </button> <button title="Exit Full Screen" class=" code-window__action-button code-window__action-button--exit-full-screen js-exit-full-screen-code-example-modal " > <i class="fas fa-compress"></i> </button> </div> <pre class="prettyprint linenums lang-cs"><code>IronPdf.ImageToPdfConverter.ImageToPdf(@"C:\images\example.png").SaveAs("example.pdf");</code></pre> <pre class="prettyprint linenums lang-vb"><code>IronPdf.ImageToPdfConverter.ImageToPdf(&quot;C:\images\example.png&quot;).SaveAs(&quot;example.pdf&quot;)</code></pre> </div> <div class="code_window_bottom"> <span class="language_selection"> <span class="ls-span">VB &nbsp;</span> <span> <label class="switch"> <input type="checkbox" checked="checked"> <span class="slider round"></span> </label> </span> <span class="ls-span">C#</span> </span> </div> </div> </div> <h2 id="anchor-combine-multiple-images-into-a-pdf-file">Combine Multiple Images Into a PDF File</h2> <p>We can also convert images to PDFs in batch into a single PDF document using <code>System.IO.Directory.EnumerateFiles</code> along with <code>ImageToPdfConverter.ImageToPdf</code>:</p> <pre class='naked-code'><code class="language-cs">string sourceDirectory = "D:\web\assets"; string destinationFile = "JpgToPDF.pdf"; var imageFiles = Directory.EnumerateFiles(sourceDirectory, "*.jpg"); ImageToPdfConverter.ImageToPdf(imageFiles).SaveAs(destinationFile);</code></pre> <div class="code-content code-content-inner"> <div class="code_window" > <div class="language-selection__content-page-wrapper"> </div> <div class="code_window_content"> <div class="code-window__action-buttons-wrapper code-window__action-buttons-wrapper--content-page"> <button title="Click to copy" class=" code-window__action-button code-window__action-button--copy copy-clipboard " data-copy-text="Click to copy" data-copied-text="Copied to clipboard" data-clipboard-id="code-explorer" data-placement="bottom" > <i class="fa-kit fa-copy-example"></i> </button> <button title="Full Screen Mode" class=" code-window__action-button code-window__action-button--full-screen js-full-screen-code-example-modal " > <i class="fas fa-expand"></i> </button> <button title="Exit Full Screen" class=" code-window__action-button code-window__action-button--exit-full-screen js-exit-full-screen-code-example-modal " > <i class="fas fa-compress"></i> </button> </div> <pre class="prettyprint linenums lang-cs"><code>string sourceDirectory = "D:\web\assets"; string destinationFile = "JpgToPDF.pdf"; var imageFiles = Directory.EnumerateFiles(sourceDirectory, "*.jpg"); ImageToPdfConverter.ImageToPdf(imageFiles).SaveAs(destinationFile);</code></pre> <pre class="prettyprint linenums lang-vb"><code>Dim sourceDirectory As String = &quot;D:\web&quot; &amp; ChrW(7) &amp; &quot;ssets&quot; Dim destinationFile As String = &quot;JpgToPDF.pdf&quot; Dim imageFiles = Directory.EnumerateFiles(sourceDirectory, &quot;*.jpg&quot;) ImageToPdfConverter.ImageToPdf(imageFiles).SaveAs(destinationFile)</code></pre> </div> <div class="code_window_bottom"> <span class="language_selection"> <span class="ls-span">VB &nbsp;</span> <span> <label class="switch"> <input type="checkbox" checked="checked"> <span class="slider round"></span> </label> </span> <span class="ls-span">C#</span> </span> </div> </div> </div> <p>Explore more about <a href="/how-to/image-to-pdf/" target="_blank" rel="nofollow noopener noreferrer">converting images to PDFs using IronPDF</a> to enhance your applications, or visit the <a href="https://ironsoftware.com" target="__blank">Iron Software website</a> to discover the entire suite of developer tools offered by Iron Software, including IronBarcode, IronOCR, and more.</p>

C# + VB.NET: Headers & Footers Headers & Footers
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}

<p>Headers and Footers may be added to PDF documents in two distinct ways.</p> <ul> <li>Classic text headers and footers, which allow text-based headers to be added, with the option to merge in dynamic data.</li> <li><a href="/examples/html-headers-and-footers/" target="_blank" rel="nofollow noopener noreferrer">HTML headers and footers with IronPDF</a>, which allow the developer to render HTML headers and footers to PDF files, also facilitating the templating of dynamic data. This method is more flexible, although it is harder to use.</li> </ul> <p>The class <code>TextHeaderFooter</code> in IronPDF defines PDF headers and footers display options. This uses a logical approach to rendering headers and footers for the most common use cases.</p> <p>In this example, we show you how to add classic text headers and footers to your PDF documents in IronPDF.</p> <p>When adding headers and footers to your document, you have the option to set the headers text to be centered on the PDF document. You can also merge metadata into your header using placeholder strings. You can find these placeholder strings in the <a href="/object-reference/api/IronPdf.TextHeaderFooter.html" target="_blank" rel="nofollow noopener noreferrer">TextHeaderFooter API Documentation</a>. You can also add a horizontal line divider between the headers or footers and the page content on every page of the PDF document, influence font and font sizes, etc. It is a very useful feature that ticks all the boxes.</p>

C# + VB.NET: HTML Headers & Footers HTML Headers & Footers
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

<p>The HTML headers and footers are rendered as independent HTML documents which may have their own assets and stylesheets. It gives developers total control over how their headers and footers look. The height of the rendered headers or footers can be controlled to match their content exactly.</p> <p>In this example, we show how to add HTML headers and footers to your PDF documents in IronPDF.</p> <p>HTML headers or footers will be printed onto every page of the PDF when you add them to your project. This can be used to override <a href="/examples/headers-and-footers/" target="_blank" rel="nofollow noopener noreferrer">IronPDF classic headers and footers examples</a>.</p> <p>When using <code>HtmlHeaderFooter</code>, it is important to set <code>HtmlFragment</code>, which will be used to render the headers or footers. It should be an HTML snippet rather than a complete document. It may also contain styles &amp; images.</p> <p>You can also merge meta-data into your HTML using any of these placeholder strings such as <code>{page} {total-pages} {url} {date} {time} {html-title} {pdf-title}</code>.</p>

C# + VB.NET: Form Data Form Data
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")

<div class="alert alert-info iron-variant-1" role="alert"> Your business is spending too much on yearly subscriptions for PDF security and compliance. Consider <a href="https://ironsoftware.com/enterprise/securedoc/">IronSecureDoc, a Comprehensive PDF Security Solution</a>, which provides solutions for managing SaaS services like digital signing, redaction, encryption, and protection, all for one-time payment. <a href="https://ironsoftware.com/enterprise/securedoc/docs/">Explore IronSecureDoc Documentation</a> </div> <p>You can create editable PDF documents with IronPDF as easily as a normal document. The <code>PdfForm</code> class is a collection of user-editable form fields within a PDF document. It can be implemented into your PDF render to make it a form or an editable document.</p> <p>This example shows you how to create editable PDF forms in IronPDF.</p> <p>PDFs with editable forms can be created from HTML simply by adding <code>&lt;form&gt;</code>, <code>&lt;input&gt;</code>, and <code>&lt;textarea&gt;</code> tags to the document parts.</p> <p>The <code>PdfDocument.Form.FindFormField</code> can be used to read and write the value of any form field. The field's name will be the same as the 'name' attribute given to that field in your HTML.</p> <p>The <code>PdfDocument.Form</code> object can be used in two ways.</p> <ul> <li>The first is to populate the default value of form fields, which must be focused in Adobe Reader to display this value.</li> <li>The second is to read data from user-filled PDF forms in any language.</li> </ul>

C# + VB.NET: Rasterize a PDF to Images Rasterize a PDF to Images
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()

<p>Use IronPDF to convert a PDF to images in your preferred file type, image dimensions, and DPI quality.</p> <p>To convert a PDF document to images, call IronPDF's <code>RasterizeToImageFiles</code> method on a <code>PdfDocument</code> object. A PDF document can be loaded using the <code>PdfDocument.FromFile</code> method or one of the available <a href="/tutorials/dotnet-core-pdf-generating/" target="_blank" rel="nofollow noopener noreferrer">PDF generation methods for .NET Core</a>.</p> <hr /> <p><div class="main-article__video-wrapper js-article-video-modal-wrapper"><iframe class="" loading="lazy" src="https://www.youtube.com/embed/1MdE_nGu0UM?start=0" title="YouTube Video Player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe></div></p> <hr /> <p><code>RasterizeToImageFiles</code> renders each page of the PDF as a rasterized image. The first argument specifies the naming pattern to use for each image. Optional arguments can be used to customize the quality and dimensions for each image. Another option allows the method to convert selected pages from the PDF into images.</p> <p>Line 24 of the featured code example demonstrates the <code>ToBitMap</code> method. Call this method on any <code>PdfDocument</code> object to quickly convert the PDF into <code>AnyBitmap</code> objects that can be saved to files or manipulated as needed.</p> <hr /> <div class="hsg-featured-snippet"> <h2>How to Convert a PDF to Images in C#</h2> <ol> <li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://nuget.org/packages/IronPdf/" target="_blank" rel="nofollow noopener noreferrer">Install the PDF to image C# library</a></li> <li>Import existing PDF file with <code>FromFile</code> method</li> <li>Convert PDF to image using <code>RasterizeToImageFiles</code> method</li> <li>Specify save directory and image size</li> <li>Check the output images</li> </ol> </div>

C# + VB.NET: Editing PDFs Editing PDFs
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

<p>IronPDF offers <a href="/features/" target="_blank" rel="nofollow noopener noreferrer">50+ features</a> for reading and editing PDFs. The most popular are <a href="/how-to/merge-or-split-pdfs/" target="_blank" rel="nofollow noopener noreferrer">merging PDFs</a>, <a href="/examples/copy-pdf-page-to-another-pdf-file/" target="_blank" rel="nofollow noopener noreferrer">cloning pages</a>, and <a href="/how-to/rotating-text/" target="_blank" rel="nofollow noopener noreferrer">extracting text from rotated content</a>.</p> <p>IronPDF also allows its users to add watermarks, rotate pages, add annotations, digitally sign PDF pages, create new PDF documents, attach cover pages, customize PDF sizes, and much more when generating and formatting PDF files. Moreover, it supports conversion of PDFs into all conventional image file types, including JPG, BMP, JPEG, GIF, PNG, TIFF, etc.</p> <p>Read <a href="/tutorials/csharp-edit-pdf-complete-tutorial/" target="_blank" rel="nofollow noopener noreferrer">the C# PDF editing tutorial</a> to learn how to make full use of IronPDF to modify PDF documents to best suit project requirements.</p> <hr /> <div class="hsg-featured-snippet"> <h2>How to Edit PDF files in C#</h2> <ol> <li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://nuget.org/packages/IronPdf/" target="_blank" rel="nofollow noopener noreferrer">Install the C# library that can edit PDF files</a></li> <li>Utilize `FromFile` method to import multiple PDF files</li> <li>Access and modify PDF file using intuitive APIs in C#</li> <li>Save the updated version as a new PDF using C#</li> <li>View the newly edited PDF document</li> </ol> </div>

C# + VB.NET: Passwords, Security & Metadata Passwords, Security & Metadata
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")

<p>IronPDF provides developers with strong PDF security options, supporting the customization and setting of PDF metadata, passwords, permissions, and more. With IronPDF's passwords, security, and metadata options, you can create custom permissions and security levels to fit the need of your PDF document. This is done thanks to the use of classes such as the <code>SecuritySettings</code> and <code>MetaData</code> classes. Some options include limiting the PDF documents to be unprintable, setting them to read-only, and 128-bit encryption, and password protection of your PDF documents. </p> <p>Setting custom metadata works by implementing the MetaData class to access the various PDF metadata options, and setting them with your customized values. This includes changing the author, keywords, modified data, and more. Setting custom security settings includes the ability to set custom user and owner passwords, printing permissions, read-only mode, and more. </p> <h2 id="anchor-5-steps-to-setting-pdf-passwords-metadata-and-security">5 Steps to setting PDF passwords, metadata, and security</h2> <ul> <li>var pdf = PdfDocument.FromFile(&quot;encrypted.pdf&quot;, &quot;password&quot;);</li> <li>System.Collections.Generic.List&lt;string&gt; metadatakeys = pdf.MetaData.Keys();</li> <li>var metadatakeys = pdf.MetaData.Keys();</li> <li>pdf.MetaData.Author = &quot;Satoshi Nakamoto&quot;;</li> <li>pdf.SecuritySettings.MakePdfDocumentReadOnly(&quot;secret-key&quot;);</li> </ul> <p>In order to begin customizing the security of your PDF documents, you must first load in an existing PDF or create a new one. Here, we have loaded an existing password-protected PDF document, where we have input the password needed to open the PDF document. Once the PDF is loaded, we then use <code>pdf.MetaData.Keys();</code> to get the PDF's current metadata. To remove existing PDF metadata values, use the <code>RemoveMetaDataKey</code> method. To begin setting new metadata value, use pdf.MetaData.metadatafield (e.g. <code>pdf.MetaData.Keywords</code>), and then just assign the new value to it. Metadata fields such as Title and Keywords take string values, whereas the ModifiedData field takes datetime values.</p> <p>Next, we have set new Security settings using the SecuritySettings class. As you can see, there are a variety of settings that you can set here. This gives you full control over the permissions and security levels for each PDF document you work with. To access these settings, you just need to make sure you use <code>pdf.SecuritySettings</code>, followed by the setting you want to adjust. For example, the <code>MakePdfDocumentReadOnly</code> property sets the PDF document to be read-only, encrypting the content at 128-bit. Other options for SecuritySettings include:</p> <ul> <li><strong>AllowUserAnnotations:</strong> Controls whether or not users can annotate the PDF.</li> <li><strong>AllowUserPrinting:</strong> Controls printing permissions for the document.</li> <li><strong>AllowUserFormData:</strong> Sets the permissions for whether users can fill-in forms.</li> <li><strong>OwnerPassword:</strong> Sets the owner password for the PDF, which is used to disable or enable the other security settings</li> <li><strong>UserPassword:</strong> Sets the user password for the PDF, which must be entered in order to open or print the document. </li> </ul> <p>Once you have set the custom metadata, passwords, and security settings for your PDF document, use the <code>pdf.SaveAs</code> method to save your PDF to a specified location.</p> <p><a href="/how-to/metadata/" target="__blank">Click here to view the How-to-Guide, including examples, sample code and files &gt;</a></p>

C# + VB.NET: PDF Watermarking PDF Watermarking
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(@"C:\Path\To\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("C:\Path\To\Watermarked.pdf")

<p>IronPDF provides methods to 'watermark' PDF documents with HTML.</p> <p>Using the <code>ApplyStamp</code> method, developers can add an HTML-based watermark to a PDF file. As shown in the example above, the HTML code for the watermark goes as the first argument to the method. Additional arguments to <code>ApplyStamp</code> control the rotation, opacity, and position of the watermark.</p> <p>Utilize the <code>ApplyStamp</code> method in lieu of the <code>ApplyWatermark</code> method for more granular control over watermark placement. For example, use <code>ApplyStamp</code> to:</p> <ul> <li>Add Text, Image, or HTML watermarks to PDFs</li> <li>Apply the same watermark to every page of the PDF</li> <li>Apply different watermarks to specific PDF pages</li> <li>Adjust the placement of watermarks in front or behind page copy</li> <li>Adjust the opacity, rotation, and alignment of watermarks with more precision</li> </ul> <hr /> <div class="hsg-featured-snippet"> <h2>How to Add Watermarks to PDF Files in C#</h2> <ol> <li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://nuget.org/packages/IronPdf/" target="_blank" rel="nofollow noopener noreferrer">Download and install the IronPDF library from NuGet.</a></li> <li>Create a new <code>PdfDocument</code> or use an existing <code>PdfDocument</code> file.</li> <li>Call the <code>ApplyWatermark</code> method to add watermarks to the PDF.</li> <li>Export the PDF file by calling <code>SaveAs</code>.</li> </ol> </div>

C# + VB.NET: Backgrounds & Foregrounds Backgrounds & Foregrounds
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(@"C:\Path\To\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("C:\Path\To\Complete.pdf")

<p>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.</p> <p>This example shows you how to use a PDF document as the background or foreground of another PDF document.</p> <p>You can do this in C# by loading or creating a multi-page PDF as an <code>IronPdf.PdfDocument</code> object.</p> <p>You can add backgrounds using <code>PdfDocument.AddBackgroundPdf</code>. For more details on background insertion methods, refer to the <a href="/object-reference/api/IronPdf.PdfDocument.html#IronPdf_PdfDocument_AddBackgroundPdf_IronPdf_PdfDocument_System_Int32_" target="_blank" rel="nofollow noopener noreferrer">IronPDF.PdfDocument background documentation</a>; 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.</p> <p>You can add foregrounds, also known as &quot;Overlays,&quot; using <code>PdfDocument.AddForegroundOverlayPdfToPage</code>. For detailed information on foreground insertion methods, consult the <a href="/object-reference/api/IronPdf.PdfDocument.html" target="_blank" rel="nofollow noopener noreferrer">IronPDF.PdfDocument overlay documentation</a>.</p>

Human Support related to .NET Core PDF Library

Support For .NET Core Coders

Regardless of whether its technical or sales inquiries, the Iron Team are close by to help with the majority of your questions. Connect with Iron to benefit as much as possible from our library in your project.

Get in Touch
C# .NET HTML-to-PDF

C# & VB HTML-to-PDF Library for .NET Core

IronPDF utilizes a Chromium renderer for .NET Chromium to convert HTML files to PDF documents. There's no need for APIs to position or layout PDFs: IronPDF uses standard HTML, ASPX, JS, CSS and Images.

See Tutorials
C# .NET PDF OCR Library

Read PDF Text

IronPDF enables you to extract all embedded text content from PDFs to pass into your C# & .NET Core APPs. Import content from PDF archives into your business process systems.

Full API Reference
How To Edit PDF Documents in C#

Edit PDFs in .NET Core

From Appending, converging, parting, and altering PDFs, utilize your own coding skills to precisely to get the correct PDF every time. IronPDF puts the development capabilities specifically into your hands, inside your C#/VB .NET Core Project.

Read Our Docs
Convert HTML5, JS, CSS and Image files to PDF documents using  .NET Code.

Supports Your Document Types

Point IronPDF .NET Core Library at your HTML file, string or URL to simply convert to PDF. This uses your current documents and website pages to render your information to a PDF file.

For ASP .NET Core, C#, VB, MVC, ASPX, .NET

Get Setup Now
Visual Studio Library for PDF Creation and Content Editing.

Get Going Fast with Microsoft Visual Studio

IronPDF puts PDF creation and editing control in your very own hands, rapidly with complete intellisense support and a Visual Studio installer. Use NuGet for Visual Studio or download the DLL. You'll be set up in a matter of moments. Only one DLL.

PM > Install-Package IronPdf Download DLL
Supports:
  • .NET Core 2 and above
  • .NET Framework 4.0 and above support C#, VB, F#
  • Microsoft Visual Studio. .NET Development IDE Icon
  • NuGet Installer Support for Visual Studio
  • JetBrains ReSharper C# language assistant compatible
  • Microsoft Azure C# .NET  hosting platform compatible

Licensing & Pricing

Free community development licenses. Commercial licenses from $749.

Project C# + VB.NET Library Licensing

Project

Developer C# + VB.NET Library Licensing

Developer

Organization C# + VB.NET Library Licensing

Organization

Agency C# + VB.NET Library Licensing

Agency

SaaS C# + VB.NET Library Licensing

SaaS

OEM C# + VB.NET Library Licensing

OEM

View Full License Options  

C# PDF Tutorials From Our Community

Tutorial + Code Examples ASPX to PDF | ASP.NET Tutorial

C# PDF ASP.NET ASPX

Jacob Müller Software Product Designer @ Team Iron

ASPX to PDF | ASP.NET Tutorial

Learn how to turn any ASP.NET ASPX page into a PDF document into a PDF instead of HTML using a single line of code in C# or VB.NET…

View Jacob's ASPX-To-PDF Example
Tutorial + Code Examples C# HTML to PDF | C Sharp & VB.NET Tutorial

C# PDF HTML

Jean Ashberg .NET Software Engineer

C# HTML to PDF | C Sharp & VB.NET Tutorial

For many this is the most efficient way to generate PDF files from .NET, because there is no additional API to learn, or complex design system to navigate…

See Jean's HTML-To-PDF Examples
Tutorial + Code Examples VB.NET PDF Creation and Editing | VB.NET & ASP.NET PDF

VB PDF ASP.NET

Veronica Sillar .NET Software Engineer

VB.NET PDF Creation and Editing | VB.NET & ASP.NET PDF

Learn how to create and edit PDF documents in VB.NET applications and websites. A free tutorial with code examples.…

View Veronica's VB.NET PDF Tutorial
Thousands of developers use IronPDF for...

Accounting and Finance Systems

  • # Receipts
  • # Reporting
  • # Invoice Printing
Add PDF Support to ASP.NET Accounting and Finance Systems

Business Digitization

  • # Documentation
  • # Ordering & Labelling
  • # Paper Replacement
C# Business Digitization Use Cases

Enterprise Content Management

  • # Content Production
  • # Document Management
  • # Content Distribution
.NET CMS PDF Support

Data and Reporting Applications

  • # Performance Tracking
  • # Trend Mapping
  • # Reports
C# PDF Reports
Iron Software Enterprise .NET Component Developers

Thousands of corporations, governments, SMEs and developers alike trust Iron software products.

Iron's team have over 10 years experience in the .NET software component market.

South Australia Government
Smith & Nephew
Turkish Airlines
Tennessee State Government
Rakuten
3M
GSK
Europcar