IRONSOFTWAREHOME

F# PDF Library (Full Tutorial)

Curtis Chau
Curtis Chau
Updated: April 22, 2026

This tutorial will guide you through the steps of how to create and edit PDF files in F# using IronPDF. All you will need is Visual Studio installed and an F# project.

To see how to use IronPDF with C# see this guide.

To see how to use IronPDF with VB.NET see this guide.

Install the F# PDF Library

Install via NuGet Package Manager

In Visual Studio, right-click on your project solution explorer and select "Manage NuGet Packages...". From there simply search for IronPDF and install the latest version. Click OK to any dialog boxes that come up. This will work in any .NET Project.

Install via NuGet Package Manager Console

You may also choose to add IronPDF through the package manager console which can be done with this command:

PM > Install-Package IronPdf

Install Directly in the .fsproj

Another option is to paste the following ItemGroup into your .fsproj file:

<ItemGroup>
  <PackageReference Include="IronPdf" Version="*" />
</ItemGroup>
XML

Install via DLL

Alternatively, the IronPDF DLL can be downloaded and manually installed to the project or GAC from https://ironpdf.com/packages/IronPdf.zip

Remember to add this statement to the top of any .fs class file using IronPDF:

open IronPdf
F#

Create a PDF from HTML with F#

Begin by opening the IronPDF library within your namespace using open. After that, create a ChromePdfRenderer object and pass an HTML string into its RenderHtmlAsPdf method. If you already have an HTML file ready, you can pass the file path string as a parameter to RenderHtmlFileAsPdf.

HTML String to PDF in F#

open IronPdf

let html = "<p>Hello World</p>"

// Initialize the PDF Renderer
let renderer = ChromePdfRenderer()

// Render HTML as PDF
let pdf = html |> renderer.RenderHtmlAsPdf

// Save the PDF document
pdf.SaveAs("document.pdf") |> ignore
F#

HTML File to PDF in F#

open IronPdf

let htmlFilePath = "C:/designs/html/layout.html"

// Initialize the PDF Renderer
let renderer = ChromePdfRenderer()

// Render HTML file as PDF
let pdf = htmlFilePath |> renderer.RenderHtmlFileAsPdf

// Save the PDF document
pdf.SaveAs("document.pdf") |> ignore
F#

Advanced IronPDF F# Template

Here is a more advanced example of creating a function that will format and style a PDF from a URL based on some rules and procedures:

open IronPdf

let CreateCompanyStandardDocument (url : string) =
    
    // Setup Render Options with desired settings
    let renderOptions = ChromePdfRenderOptions(
        CssMediaType = Rendering.PdfCssMediaType.Screen,
        EnableJavaScript = true,
        PrintHtmlBackgrounds = true,
        InputEncoding = System.Text.Encoding.UTF8,
        MarginTop = 10,
        MarginBottom = 10,
        MarginLeft = 10,
        MarginRight = 10
    )
    
    // Create Header Template for the PDF
    let companyStyleHeader = HtmlHeaderFooter()
    companyStyleHeader.HtmlFragment <- "<img src='https://ironsoftware.com/img/svgs/ironsoftware-logo-black.svg'>"
    companyStyleHeader.DrawDividerLine <- true
    
    // Apply the header to the Render Options
    renderOptions.HtmlHeader <- companyStyleHeader
    
    // Initialize Renderer with customized options
    let renderer = ChromePdfRenderer(RenderingOptions = renderOptions)
    
    // Generate PDF from URL without additional styles
    let htmlPdfWithoutStyle = url |> renderer.RenderUrlAsPdf
    
    // Add the styled header to the PDF document
    htmlPdfWithoutStyle.AddHtmlHeaders companyStyleHeader |> ignore
    
    // Return the created PDF document
    htmlPdfWithoutStyle
   
let IronPdfUrlToPdf (url : string) =
    // Create a styled PDF document from the given URL
    let pdf = url |> CreateCompanyStandardDocument
    
    // Save the PDF document to the file system
    pdf.SaveAs("document.pdf") |> ignore

// Set your IronPDF License Key
IronPdf.License.LicenseKey <- "YOUR_LICENSE_KEY_HERE"

// Example usage: Convert the given URL to a PDF document
IronPdfUrlToPdf "https://ironpdf.com/"
F#

Frequently Asked Questions

How can I generate a PDF file using F# in .NET 10?

You can generate a PDF file using F# in .NET 10 by utilizing IronPDF's ChromePdfRenderer class. Start by installing IronPDF via NuGet Package Manager, and then use methods like RenderHtmlAsPdf to convert HTML strings or files into PDF documents.

What installations are required to use IronPDF with F#?

To use IronPDF with F#, you can install it via the NuGet Package Manager, the Package Manager Console by using a command, directly add it to your .fsproj file, or manually use the DLL. Each method requires adding 'open IronPdf' at the top of your .fs files to access IronPDF functionalities.

Can I customize the PDF document styles using IronPDF in F#?

Yes, you can customize the PDF document styles in F# using IronPDF. Use the ChromePdfRenderOptions to set parameters such as margin sizes, enable JavaScript, and handle CSS while rendering HTML to PDF.

How do I convert an HTML file to a PDF using IronPDF in F#?

To convert an HTML file to a PDF using IronPDF in F#, initialize a ChromePdfRenderer and pass your HTML file path to the RenderHtmlFileAsPdf method, which will then create a PDF document that you can save.

Is it possible to add headers and footers to PDFs using IronPDF in F#?

Yes, you can add headers and footers to PDFs with IronPDF in F#. Use the HtmlHeaderFooter class to create a header template, apply it to your ChromePdfRenderOptions, and incorporate it when rendering your PDF.

What are the basic steps to create a PDF from a URL in F#?

To create a PDF from a URL in F#, define the desired rendering options with ChromePdfRenderOptions, optionally customize with headers or footers, and use the RenderUrlAsPdf method of ChromePdfRenderer to generate the PDF.

Can IronPDF render HTML files with external resources in F#?

Yes, IronPDF can render HTML files with external resources such as CSS and images when using F#. Ensure that paths are correctly referenced, and render the HTML file with RenderHtmlFileAsPdf for complete PDFs.

What is the function of the 'LicenseKey' in IronPDF?

The 'LicenseKey' in IronPDF is necessary to unlock the full features of the library. It allows you to deploy IronPDF applications without trial limitations. Set it in your code using 'IronPdf.License.LicenseKey'.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 21,105,021Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999