IRONSOFTWAREHOME
Cookies
using IronPdf;

// Instantiate ChromePdfRenderer
ChromePdfRenderer renderer = new ChromePdfRenderer();

renderer.RenderingOptions.RequestContext = IronPdf.Rendering.RequestContexts.Global;

ChromeHttpLoginCredentials credentials = new ChromeHttpLoginCredentials()
{
    NetworkUsername = "testUser",
    NetworkPassword = "testPassword"
};
string uri = "http://localhost:51169/Invoice";

// Apply cookies
renderer.ApplyCookies(uri, credentials);
Imports IronPdf

' Instantiate ChromePdfRenderer
Dim renderer As New ChromePdfRenderer()

renderer.RenderingOptions.RequestContext = IronPdf.Rendering.RequestContexts.Global

Dim credentials As New ChromeHttpLoginCredentials() With {
    .NetworkUsername = "testUser",
    .NetworkPassword = "testPassword"
}
Dim uri As String = "http://localhost:51169/Invoice"

' Apply cookies
renderer.ApplyCookies(uri, credentials)
NuGet Download
PM > Install-Package IronPdf
Cookies

Cookies

This code demonstrates how to use IronPDF to authenticate a request using network credentials and apply cookies for rendering a webpage as a PDF.

  • ChromePdfRenderer: Used for rendering HTML content into PDF format.
  • RequestContexts.Global: Ensures that the PDF rendering maintains the same browsing context for the lifetime of the process, enabling the use of cookies and authentication across requests.
  • ChromeHttpLoginCredentials: Provides network authentication when accessing web pages that require login credentials.
  • ApplyCookies: Applies the specified cookies and credentials to the HTTP request, vital for rendering secure pages.
  • uri: Represents the web address of a page that needs to be rendered into a PDF and typically requires user authentication. In this example, it points to a locally hosted webpage.

This setup is particularly advantageous when rendering PDFs from authenticated pages, such as invoices, reports, or dashboards that require user authentication.

Learn to Apply Cookies in PDF Rendering with IronPDF.
View on GitHub

Ready to Get Started?

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

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