IRONSOFTWAREHOME
TLS Website & System Logins
using IronPdf;
using System;
using System.IO;

var uri = new Uri("http://localhost:51169/Invoice");
var urlToPdf = new ChromePdfRenderer
{
    RenderingOptions = new ChromePdfRenderOptions()
    {
        MarginTop = 50,
        MarginBottom = 50,
        TextHeader = new TextHeaderFooter()
        {
            CenterText = "{pdf-title}",
            DrawDividerLine = true,
            FontSize = 16
        },
        TextFooter = new TextHeaderFooter()
        {
            LeftText = "{date} {time}",
            RightText = "Page {page} of {total-pages}",
            DrawDividerLine = true,
            FontSize = 14
        },
        CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print
    },

    // setting login credentials to bypass basic authentication
    LoginCredentials = new IronPdf.ChromeHttpLoginCredentials
    {
        NetworkUsername = "testUser",
        NetworkPassword = "testPassword"
    }
};

var pdf = urlToPdf.RenderUrlAsPdf(uri);
pdf.SaveAs(Path.Combine(Directory.GetCurrentDirectory(), "UrlToPdfExample2.Pdf"));
Imports IronPdf
Imports System
Imports System.IO

Dim uri = New Uri("http://localhost:51169/Invoice")
Dim urlToPdf = New ChromePdfRenderer With {
    .RenderingOptions = New ChromePdfRenderOptions() With {
        .MarginTop = 50,
        .MarginBottom = 50,
        .TextHeader = New TextHeaderFooter() With {
            .CenterText = "{pdf-title}",
            .DrawDividerLine = True,
            .FontSize = 16
        },
        .TextFooter = New TextHeaderFooter() With {
            .LeftText = "{date} {time}",
            .RightText = "Page {page} of {total-pages}",
            .DrawDividerLine = True,
            .FontSize = 14
        },
        .CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print
    },
    .LoginCredentials = New IronPdf.ChromeHttpLoginCredentials With {
        .NetworkUsername = "testUser",
        .NetworkPassword = "testPassword"
    }
}

Dim pdf = urlToPdf.RenderUrlAsPdf(uri)
pdf.SaveAs(Path.Combine(Directory.GetCurrentDirectory(), "UrlToPdfExample2.Pdf"))
NuGet Download
Install-Package IronPdf
TLS Website & System Logins

TLS Website & System Logins

Most ASP.NET applications support network authentication, a more reliable method than HTML form posting, and with IronPDF, you can be assured that TLS network authentication is fully supported. This means you can work within secure, .NET web app-supported environments.

Take this code, for example, we use IronPDF's powerful Chromium-based rendering engine to render the web page as if it were being viewed in a browser, wherein the headers and footers are dynamically generated and added to the pages. Then, margins and styles are applied accordingly before the result is saved as a professional-looking PDF.

Steps for Rendering PDFs with TLS Website and System Logins

  1. Define the Web Page URL:
    • The first step in this process is to define the web page URL. We create a new uri object representing the URL of the web page we want to render as a PDF. In this example, the page is hosted locally at "http://localhost:51169/Invoice".
  2. Create the PDF Renderer:
    • Create a new instance of ChromePdfRenderer, which handles the conversion of web pages to PDF using its powerful conversion features.
  3. Set Rendering Options:
    • Use the RenderingOptions property to configure the rendering options. Custom margins and media type for printing styles (IronPdf.Rendering.PdfCssMediaType.Print) are demonstrated here.
  4. Set Login Credentials:
    • Configure LoginCredentials if the URL requires basic authentication. Here, placeholders for Username and Password are provided.
  5. Render the URL as a PDF:
    • Use the RenderUrlAsPdf method to open the given uri within a headless Chromium browser and convert the web page into a PDF using the specified rendering options.
  6. Save the PDF:
    • Finally, save the PDF using the SaveAs method to the current working directory with the filename "UrlToPdfExample2.Pdf".
Learn to Secure PDFs with Login Integration Now
View on GitHub

Ready to Get Started?

Nuget Downloads 20,389,208Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge related to IronPDF Product Demo

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