C# VB PDF .Net : Using Html To Create a PDF Using Html To Create a PDF
// PM> Install-Package IronPdf

using IronPdf;

var Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").SaveAs("pixel-perfect.pdf");

 
/****** Advanced ******/

// 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 PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
PDF.SaveAs("html-with-assets.pdf");
' PM> Install-Package IronPdf

Imports IronPdf

Private Renderer = New IronPdf.ChromePdfRenderer()
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").SaveAs("pixel-perfect.pdf")


'''**** Advanced *****

' 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 PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")
PDF.SaveAs("html-with-assets.pdf")

IronPDF allows developers to create PDF documents easily in C#, F#, and VB.Net for .NET Core and .NET Framework.

In this example we show that a PDF document can be rendered using HTML.

You can choose simple HTML like the above, or incorporate CSS, images and Javascript.

IronPDF's rendering is "pixel perfect" to desktop versions of Google Chrome.

C# VB PDF .Net : Converting a URL to a PDF Converting a URL to a PDF
// PM> Install-Package IronPdf

using IronPdf;


IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");

Pdf.SaveAs("url.pdf");  
// see also Pdf.Stream
' PM> Install-Package IronPdf

Imports IronPdf


Private Renderer As New IronPdf.ChromePdfRenderer()
Private Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/")

Pdf.SaveAs("url.pdf")
' see also Pdf.Stream

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.

Rendering PDFs from ASP.NET URLs which accept query string variables can make PDF development an easy collaboration between designers and coders.

C# VB PDF .Net : PDF Generation Settings PDF Generation Settings
// PM> Install-Package IronPdf

using IronPdf;

IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();

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.RenderDelay = 50; //ms
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen;
Renderer.RenderingOptions.FitToPaper = false;
Renderer.RenderingOptions.Zoom = 100;
Renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

Renderer.RenderingOptions.MarginTop = 40;  //millimeters
Renderer.RenderingOptions.MarginLeft = 20;  //millimeters
Renderer.RenderingOptions.MarginRight = 20;  //millimeters
Renderer.RenderingOptions.MarginBottom = 40;  //millimeters

Renderer.RenderingOptions.FirstPageNumber = 1; //use 2 if a coverpage  will be appended

Renderer.RenderHTMLFileAsPdf("my-content.html").SaveAs("my-content.pdf");
' PM> Install-Package IronPdf

Imports IronPdf

Private Renderer As New IronPdf.ChromePdfRenderer()

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.RenderDelay = 50 'ms
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen
Renderer.RenderingOptions.FitToPaper = False
Renderer.RenderingOptions.Zoom = 100
Renderer.RenderingOptions.CreatePdfFormsFromHtml = True

Renderer.RenderingOptions.MarginTop = 40 'millimeters
Renderer.RenderingOptions.MarginLeft = 20 'millimeters
Renderer.RenderingOptions.MarginRight = 20 'millimeters
Renderer.RenderingOptions.MarginBottom = 40 'millimeters

Renderer.RenderingOptions.FirstPageNumber = 1 'use 2 if a coverpage  will be appended

Renderer.RenderHTMLFileAsPdf("my-content.html").SaveAs("my-content.pdf")

IronPDF supports many customizations for generated PDF file formats including: Paper Sizes, Document output quality, Content Scaling, CSS 'media types' and JavaScript Support.

C# VB PDF .Net : Rendering ASPX Pages as PDFs Rendering ASPX Pages as PDFs
private void Form1_Load(object sender, EventArgs e)
{

IronPdf.AspxToPdf.RenderThisPageAsPdf();
//Changes the ASPX output into a pdf instead of HTML

}
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)

IronPdf.AspxToPdf.RenderThisPageAsPdf()
'Changes the ASPX output into a pdf instead of HTML

End Sub

Using the IronPDF library, ASP.NET web pages can be rendered to PDF instead of HTML by adding a single line of code to the Form_Load event. This allows complex PDFs to be data driven, and designed and tested as HTML first for simplicity.

C# VB PDF .Net : HTML or Image File to PDF HTML or Image File to PDF
 // PM> Install-Package IronPdf
using IronPdf;

// Create a PDF from an existing HTML using C#
var Renderer = new IronPdf.ChromePdfRenderer();
var PDF = Renderer.RenderHTMLFileAsPdf("Invoice.html");

// HTML assets such as images, css and JS will be automatically loaded. 

PDF.SaveAs("Invoice.pdf"); // oruse PDF.Stream
' PM> Install-Package IronPdf
Imports IronPdf

' Create a PDF from an existing HTML using C#
Private Renderer = New IronPdf.ChromePdfRenderer()
Private PDF = Renderer.RenderHTMLFileAsPdf("Invoice.html")

' HTML assets such as images, css and JS will be automatically loaded. 

PDF.SaveAs("Invoice.pdf") ' oruse PDF.Stream

We can also render any HTML file on our hard disk.

All relative assets such as CSS, images and js will be rendered as if the file had been opened using the file:// protocol.

This method has the advantage of allowing the developer the opportunity to test the HTML content in a browser during development. We recommend Chrome as being the web browser on which IronPDF's rendering engine is based.

C# VB PDF .Net : ASPX To PDF Settings ASPX To PDF Settings
// PM> Install-Package IronPdf
using IronPdf;


var PdfOptions = new IronPdf.Rendering.AdaptivePdfRenderOptions()
{
    CreatePdfFormsFromHtml = true,
    EnableJavaScript = false,
    Title = "My ASPX Page Rendered as a PDF"
    //.. many more options available
};

AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "MyPdfFile.pdf", PdfOptions);
' PM> Install-Package IronPdf
Imports IronPdf


Private PdfOptions = New IronPdf.Rendering.AdaptivePdfRenderOptions() With {
	.CreatePdfFormsFromHtml = True,
	.EnableJavaScript = False,
	.Title = "My ASPX Page Rendered as a PDF"
}

AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "MyPdfFile.pdf", PdfOptions)

ASP.NET ASPX to PDF functionality allows the full set of options available when rendering HTML from a string or file, but adds 2 new options:
- Changing the PDF file name
- Your PDF may be displayed directly in the web browser, or as a file download.

C# VB PDF .Net : Image To PDF Image To PDF
// PM> Install-Package IronPdf
using IronPdf;
using System.IO;
using System.Linq;

// One or more images as IEnumerable.  This example selects all JPEG images in a specific folder.
var ImageFiles = System.IO.Directory.EnumerateFiles(@"C:\project\assets").Where(f => f.EndsWith(".jpg") || f.EndsWith(".jpeg"));

// Convert the images to a PDF and save it.
ImageToPdfConverter.ImageToPdf(ImageFiles).SaveAs(@"C:\project\composite.pdf");

//Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
' PM> Install-Package IronPdf
Imports IronPdf
Imports System.IO
Imports System.Linq

' One or more images as IEnumerable.  This example selects all JPEG images in a specific folder.
Private ImageFiles = System.IO.Directory.EnumerateFiles("C:\project\assets").Where(Function(f) f.EndsWith(".jpg") OrElse f.EndsWith(".jpeg"))

' Convert the images to a PDF and save it.
ImageToPdfConverter.ImageToPdf(ImageFiles).SaveAs("C:\project\composite.pdf")

'Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails

PDF documents can be easily constructed from one or more image files using the IronPdf.ImageToPdfConverter Class.

C# VB PDF .Net : HTML Headers & Footers HTML Headers & Footers
// PM> Install-Package IronPdf
using IronPdf;


IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();


  // Build a footer using html to style the text
  // mergable 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
  };

  // Build a header using an image asset
  // Note the use of BaseUrl to set a relative path to the assets
  Renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
  {
      MaxHeight = 20, //millimeters
      HtmlFragment = "<img src='logo.png'>",
      BaseUrl = new Uri(@"C:\assets\images\").AbsoluteUri
  };
' PM> Install-Package IronPdf
Imports IronPdf


Private Renderer As New IronPdf.ChromePdfRenderer()


  ' Build a footer using html to style the text
  ' mergable 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
  }

  ' Build a header using an image asset
  ' Note the use of BaseUrl to set a relative path to the assets
  Renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter() With {
	  .MaxHeight = 20,
	  .HtmlFragment = "<img src='logo.png'>",
	  .BaseUrl = (New Uri("C:\assets\images\")).AbsoluteUri
  }

HTML Headers and Footers are rendered as independent HTML documents which may have their own assets and stylesheets. Developers may control the Height of the rendered Header or Footer to match their content exactly.

C# VB PDF .Net : Simple Headers & Footers Simple Headers & Footers
// PM> Install-Package IronPdf

using IronPdf;


IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();

// Add a header to every page easily
Renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a coverpage  will be appended
Renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
Renderer.RenderingOptions.TextHeader.CenterText = "{url}";
Renderer.RenderingOptions.TextHeader.FontFamily = "Helvetica,Arial";
Renderer.RenderingOptions.TextHeader.FontSize = 12;

// Add a footer too
Renderer.RenderingOptions.TextFooter.DrawDividerLine = true;
Renderer.RenderingOptions.TextFooter.FontFamily = "Arial";
Renderer.RenderingOptions.TextFooter.FontSize = 10;
Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}";
Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";

// Mergable fields are:
// {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
' PM> Install-Package IronPdf

Imports IronPdf


Private Renderer As New IronPdf.ChromePdfRenderer()

' Add a header to every page easily
Renderer.RenderingOptions.FirstPageNumber = 1 ' use 2 if a coverpage  will be appended
Renderer.RenderingOptions.TextHeader.DrawDividerLine = True
Renderer.RenderingOptions.TextHeader.CenterText = "{url}"
Renderer.RenderingOptions.TextHeader.FontFamily = "Helvetica,Arial"
Renderer.RenderingOptions.TextHeader.FontSize = 12

' Add a footer too
Renderer.RenderingOptions.TextFooter.DrawDividerLine = True
Renderer.RenderingOptions.TextFooter.FontFamily = "Arial"
Renderer.RenderingOptions.TextFooter.FontSize = 10
Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"
Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"

' Mergable fields are:
' {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}

Headers and Footers may be added to PDF documents in 2 distinct ways.
- TextHeaderFooter allows text based headers to be added, with the option to merge in dynamic data.
- HtmlHeaderFooter allows the developer to render HTML headers and footers to PDF files, also allowing the templating of dynamic data. More felxible but harder to use.

C# VB PDF .Net : Editing PDFs Editing PDFs
// PM> Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

var Renderer = new IronPdf.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"));
PdfDocument 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("exerpt.pdf");
' PM> Install-Package IronPdf
Imports IronPdf
Imports System.Collections.Generic

Private Renderer = New IronPdf.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 As PdfDocument = 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("exerpt.pdf")

IronPDF allows many PDF file editing manipulations. The most popular are merging, cloning and extracting pages.

PDF may also be watermarked, stamped and have backgrounds and foregrounds applied.

C# VB PDF .Net : Passwords, Security and MetaData Passwords, Security and MetaData
// PM> Install-Package IronPdf

//Open an Encrypted File, alternatively create a new PDF from Html

PdfDocument Pdf = PdfDocument.FromFile("encrypted.pdf", "password");

//Edit file metadata
Pdf.MetaData.Author = "Satoshi Nakamoto";
Pdf.MetaData.Keywords = "SEO, Friendly";
Pdf.MetaData.ModifiedDate = DateTime.Now;

//Edit file security settings

//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 encrpytion password
Pdf.SecuritySettings.OwnerPassword = "top-secret"; // password to edit the pdf
Pdf.SecuritySettings.UserPassword = "sharable";  // password to open the pdf
Pdf.SaveAs("secured.pdf");



 
' PM> Install-Package IronPdf

'Open an Encrypted File, alternatively create a new PDF from Html

Dim Pdf As PdfDocument = PdfDocument.FromFile("encrypted.pdf", "password")

'Edit file metadata
Pdf.MetaData.Author = "Satoshi Nakamoto"
Pdf.MetaData.Keywords = "SEO, Friendly"
Pdf.MetaData.ModifiedDate = DateTime.Now

'Edit file security settings

'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 encrpytion password
Pdf.SecuritySettings.OwnerPassword = "top-secret" ' password to edit the pdf
Pdf.SecuritySettings.UserPassword = "sharable" ' password to open the pdf
Pdf.SaveAs("secured.pdf")

Granular meta-data and security settings can be applied. This now includes the ability to limit PDF documents to be unprintable, read only and encrypted. 128 bit encryption, decryption and password protection of PDF documents is supported.

C# VB PDF .Net : PDF Watermarking PDF Watermarking
// PM> Install-Package IronPdf
using IronPdf;

// Stamps a watermark onto a new or existing PDF
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();

var Pdf = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
Pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>",  IronPdf.Editing.WaterMarkLocation.MiddleCenter, 50, -45, "https://www.nuget.org/packages/IronPdf");
Pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
' PM> Install-Package IronPdf
Imports IronPdf

' Stamps a watermark onto a new or existing PDF
Private Renderer As New IronPdf.ChromePdfRenderer()

Private Pdf = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
Pdf.WatermarkAllPages("<h2 style='color:red'>SAMPLE</h2>", IronPdf.Editing.WaterMarkLocation.MiddleCenter, 50, -45, "https://www.nuget.org/packages/IronPdf")
Pdf.SaveAs("C:\Path\To\Watermarked.pdf")

IronPDF provides methods to 'watermark' PDF documents with HTML. Watermarks may be set to render above or below existing content, and have built in capacity for opacity, rotation and hyperlinks.

C# VB PDF .Net : Backgrounds & Foregrounds Backgrounds & Foregrounds
// PM> Install-Package IronPdf
using IronPdf;

// With IronPDF, we can easily merge 2 PDF files using one as a backgorund or foreground
IronPdf.ChromePdfRenderer Renderer = new IronPdf.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");
' PM> Install-Package IronPdf
Imports IronPdf

' With IronPDF, we can easily merge 2 PDF files using one as a backgorund or foreground
Private Renderer As New IronPdf.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")

An existing or rendered PDF may be used as the Background or Foreground for another PDF document. This is particularly useful for design consistency and templating.

How add a Background (or overlay) to a PDF in C#

  1. Load or create a multi-page PDF as an IronPdf.PdfDocument object.
  2. You can add backgrounds using PdfDocument.AddBackgroundPdf. There are several background insertion methods and overrides in the IronPdf.PdfDocument documentation
  3. You can add Foregrounds also known as "Overlays" using PdfDocument.AddForegroundOverlayPdfToPage. There are several foreground insertion methods and overrides in the IronPdf.PdfDocument documentation
  4. Save the PDF to disk, or serve it as a FileActionResult via MVC.

C# VB PDF .Net : Form Data Form Data
           
// PM> Install-Package IronPdf
using IronPdf;

// Step 1.  Creating a PDF with editable forms from HTML using form and input tags

var 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='' >
        </form>
    </body>
</html>";

IronPdf.ChromePdfRenderer Renderer = new IronPdf.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.GetFieldByName("firstname");
FirstNameField.Value = "Minnie";
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value);

//Set and Read the value of the "lastname" field
IronPdf.Forms.FormField LastNameField = FormDocument.Form.GetFieldByName("lastname");
LastNameField.Value = "Mouse";
Console.WriteLine("LastNameField value: {0}", LastNameField.Value);

FormDocument.SaveAs("FilledForm.pdf");
' PM> Install-Package IronPdf
Imports IronPdf

' Step 1.  Creating a PDF with editable forms from HTML using form and input tags

Private 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='' >
        </form>
    </body>
</html>"

Private Renderer As New IronPdf.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.GetFieldByName("firstname")
FirstNameField.Value = "Minnie"
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value)

'Set and Read the value of the "lastname" field
Dim LastNameField As IronPdf.Forms.FormField = FormDocument.Form.GetFieldByName("lastname")
LastNameField.Value = "Mouse"
Console.WriteLine("LastNameField value: {0}", LastNameField.Value)

FormDocument.SaveAs("FilledForm.pdf")

PDFs with editable forms can be created from HTML simply by adding <form>, <input>, and <textarea> tags. The PdfDocument.Form.GetFieldByName can be used to read and write the value of any form field. The name of the field will be the same as the 'name' attribute given to that field in your HTML. The PdfDocument.Form object can be used to:
- Populate the default value of form fields (must be focused in Adobe Reader to display this value)
- Read data from user filled PDF forms in any language.

C# VB PDF .Net : Rasterize a PDF to Images Rasterize a PDF to Images
// PM> Install-Package IronPdf
using IronPdf;
using System.Drawing;


//Example rendering PDF documents to Images or Thumbnails

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\thumbnail_*.jpg", 100, 80);


//Extract all pages as System.Drawing.Bitmap objects
System.Drawing.Bitmap[] pageImages = Pdf.ToBitmap();
' PM> Install-Package IronPdf
Imports IronPdf
Imports System.Drawing


'Example rendering PDF documents to Images or Thumbnails

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\thumbnail_*.jpg", 100, 80)


'Extract all pages as System.Drawing.Bitmap objects
Dim pageImages() As System.Drawing.Bitmap = Pdf.ToBitmap()

IronPDF allows any PDF document to be exported to image files in convenient formats or Bitmap objects. Image dimensions and page number ranges may also be specified.

C# VB PDF .Net : Digitally Sign a PDF Digitally Sign a PDF
// PM> Install-Package IronPdf
using IronPdf;


//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
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
PdfDocument 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
signature.SigningContact = "support@ironsoftware.com";
signature.SigningLocation = "Chicago, USA";
signature.SigningReason = "To show how to sign a PDF";
signature.LoadSignatureImageFromFile("handwriting.png");

//Step 4. Sign the PDF with the PdfSignature. Multiple signing certificates may be used
doc.SignPdfWithDigitalSignature(signature);

//Step 4. The PDF is not signed until saved to file, steam or byte array.
doc.SaveAs("signed.pdf");
' PM> Install-Package IronPdf
Imports IronPdf


'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 As New IronPdf.ChromePdfRenderer()
Dim doc As PdfDocument = 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")

' Step 3. Optional signing options and a handwritten signature graphic
signature.SigningContact = "support@ironsoftware.com"
signature.SigningLocation = "Chicago, USA"
signature.SigningReason = "To show how to sign a PDF"
signature.LoadSignatureImageFromFile("handwriting.png")

'Step 4. Sign the PDF with the PdfSignature. Multiple signing certificates may be used
doc.SignPdfWithDigitalSignature(signature)

'Step 4. The PDF is not signed until saved to file, steam or byte array.
doc.SaveAs("signed.pdf")

IronPDF has options to digitally sign new or existing PDF files using .pfx and .p12 X509Certificate2 digital certificates.

Once a PDF is signed, it can not be modified without the certificate being invalidated. This ensures fidelity.

To generate a signing certificate for free using Adobe Reader, please read https://helpx.adobe.com/acrobat/using/digital-ids.html

In addition to cryptographic signing, a hand written signature image or company stamp image may also be used to sign using IronPDF.

HTML to PDF in ASP .Net

What Is IronPDF for .Net?

Our .NET PDF Library solution is a dream for developers, especially software engineers who use C#. You can easily create a core pdf library for .NET.

IronPDF uses a .Net Chromium engine to render HTML pages to PDF files. There's no need to use complex APIs to position or design PDFs. IronPDF supports standard web documents HTML, ASPX, JS, CSS, and images.

It enables you to create a .NET PDF library using HTML5, CSS, Javascript, and also images. You can edit, stamp, and add headers and footers to a PDF effortlessly. It also makes it easy to read PDF text and extract images!

Get Started
.NET PDF Library Features Using IronPDF

.NET PDF Library Features Using IronPDF

We’ve never seen a more accurate HTML to PDF converter! Our industry-leading PDF library has so many features and a rendering engine that enables heedlessness and embeddability in the Chrome / Webkit. No installation is required.

Create

  • Create PDF documents from HTML 4 and 5, CSS, and JavaScript
  • Generate PDF documents from URL
  • Load URL with custom network login credentials, UserAgents, Proxies, Cookies, HTTP headers, form variables allowing login behind HTML login forms
    • Supports mainstream icon fonts (Fontello, Bootstrap, FontAwesome)
    • Load external stylesheets and assets (HTTP, HTTPS, or filesystem) programmatically
  • Single and Multithreaded rendering
  • Custom ISO paper size with customizable orientations, margins, and color component

Edit Existing PDF Documents without Adobe Acrobat

  • Read and fill form fields data
  • Extract images and texts from PDF
  • Add, edit, update outlines and bookmarks, program annotations with sticky notes
  • Add foreground or background overlays from HTML or PDF assets
  • Stamp new HTML Content onto any existing PDF page
  • Add logical or HTML headers and footers

Manipulate Existing PDF Documents

  • Load and parse existing PDF documents
  • Merge and split content in pdf document
  • Add headers, footers, annotations, bookmarks, watermarks, text, and image assets
  • Add stamp and watermarks with text, images, and HTML backgrounds
  • Rotate pages

Convert from Multiple Formats

  • Images to a PDF file – convert from mainstream image document, with a single line code, JPG, PNG, GIF, BMP, TIFF, system drawing, and SVG to PDF
  • ASPX WebForms – convert, with 3 lines of code, ASP.NET webforms to downloadable PDFs viewable in the browser
  • HTML Document – convert HTML to PDF
  • Custom ‘base URL’ to allow accessible asset files across the web
  • Responsive layouts through Virtual Viewport (Width and Height)
  • Custom zoom with scalable:
    • HTML content to dimensions that preserves the quality
    • Output resolution in DPI
  • Embed System Drawing image assets into HTML strings with ImagetoDataURI
  • Enable Javascript support including optional Render delays
  • Accept HTML encoded in any major file encoding (Default to UTF-8)

Export

  • MVC Views – export ASP.NET MVC views as PDF
  • Merge pages and images
  • Export files to any format with supported fonts

Save

  • Save and load from file, binary data, or MemoryStreams.

Secure

  • Improve security with options to update user passwords, metadata, security permissions, and verifiable digital signatures

Print

  • Screen or Print CSS media types
  • Turn PDF files into a PrintDocument object and print without Adobe (with minimal code)

See the Features
Edit PDFs in C# VB .Net

Everything you need in PDF documents

Creating, merging, splitting, editing, and manipulating PDF files whenever you want them, the way you want them is a breeze. Use your C# development skills to tap into IronPDF’s expanding features list.

To begin working on a project with IronPDF, download the free Nuget Package Installer or directly download the DLL. You can then proceed to create PDF document, edit and manipulate existing file formats, or export to any format without adobe acrobat.

Our support extends from a free and exhaustive range of tutorials to 24/7 live support.

Get Started with IronPDF
HTML, Javascript, CSS and Image Conversion to PDF in .Net Applications.

Design with Familiar HTML Documents

IronPDF lets you work with mainstream HTML document formats and turn it into PDF in ASP.NET web applications. Apply multiple settings including setting file behavior and names, adding headers and footers, changing print options, adding page breaks, combining async and multithreading, and more.

Similarly you can convert C# MVC HTML to PDF for ASP .NET Applications, print MVC view to return PDF file format, supported with HTML, CSS, Javascript and images.

In addition, create PDF documents and convert a present HTML page to PDF in ASP .NET C# applications and websites (C# html-to-pdf converter). The rich HTML is used as the PDF content with the ability to edit and manipulate with IronPDF's generate feature.

With IronPDF, worrying about resolutions is an issue from the past. The output PDF documents from IronPdf are pixel identical to the PDF functionality in the Google Chrome web browser.

Made for .Net, C#, VB, MVC, ASPX, ASP.NET, .NET Core

Get Started in Minutes
Simple Installation <br/>for Visual Studio

Try It With NuGet Now

The benefits are clear! With IronPDF, you can do so much more, so much easier. Our product is perfect for anyone who needs to make, manage and edit a library of PDFs, including businesses in real estate, publishing, finance, and enterprise. The prices of our solution are also very competitive.

Ready to see what Iron PDF can do for your projects and business? Try it out now

Install with Nuget for .Net Download Now
Supports:
  • Supports C#, VB in .Net Framework 4.0 and above
  • Nuget Installer Support for Visual Studio
  • .Net Core 2 and above
  • .Net Development IDE - Microsoft Visual Studio.
  • Azure for .NET cloud hosting
  • JetBrains ReSharper C# compatible

IronPDF Licensing

Free for development purposes. Deployment licenses from $399.

Project C# + VB.NET Library Licensing

Project

Organization C# + VB.NET Library Licensing

Organization

SaaS C# + VB.NET Library Licensing

SaaS

OEM C# + VB.NET Library Licensing

OEM

Developer C# + VB.NET Library Licensing

Developer

Agency C# + VB.NET Library Licensing

Agency

Licensing IronPDF for Deployment  

PDF C# / VB Tutorials for .Net

C# HTML-to-PDF | C Sharp & VB.Net Tutorial

C# PDF HTML

Jean Ashberg .Net Software Engineer

Tutorial | CSharp and VB .Net HTML to PDF

Let's create PDFs in .Net, without the need for complex programtic design layout or APIs…

View Jean's HTML To PDF Tutorial
ASPX to PDF | ASP.NET Tutorial

C# PDF .NET ASPX

Jacob Müller Software Product Designer @ Team Iron

Tutorial | ASPX to PDF in ASP.NET

See how easy it is to convert ASPX pages into PDF documents using C# or VB .Net…

See Jacob's ASPX To PDF Tutorial
VB.Net | VB .Net PDF Tutorial

VB.NET PDF ASP.NET

Veronica Sillar .Net Software Engineer

Tutorial | Create PDFs with VB.Net

See how I use IronPDF to create PDF documents within my VB .Net projects…

See Veronica's VB .Net 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
Install IronPDF Now
IronPDF Component software library customers

Developers working within Companies, Government departments and as freelancers use IronPDF.

IronPDF is constantly supported as a leading .Net PDF Library

Iron Pdf Customer Icon
Iron Pdf Customer Icon
Iron Pdf Customer Icon
Iron Pdf Customer Icon
Iron Pdf Customer Icon
Iron Pdf Customer Icon
Iron Pdf Customer Icon
Iron Pdf Customer Icon