IRONSOFTWAREHOME
Website & System Logins
from ironpdf import *
 
url = "http://localhost:51169/Invoice"
renderer = ChromePdfRenderer()
renderer.RenderingOptions = ChromePdfRenderOptions()
renderer.RenderingOptions.MarginTop = 50
renderer.RenderingOptions.MarginBottom = 50
renderer.RenderingOptions.TextHeader = TextHeaderFooter()
renderer.RenderingOptions.TextHeader.CenterText = "{pdf-title}"
renderer.RenderingOptions.TextHeader.DrawDividerLine = True
renderer.RenderingOptions.TextHeader.FontSize = 16
renderer.RenderingOptions.TextFooter = TextHeaderFooter()
renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"
renderer.RenderingOptions.TextFooter.RightText = "Page {page} of {total-pages}"
renderer.RenderingOptions.TextFooter.DrawDividerLine = True
renderer.RenderingOptions.TextFooter.FontSize = 14
renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print

# setting login credentials to bypass basic authentication
renderer.LoginCredentials = ChromeHttpLoginCredentials()
renderer.LoginCredentials.NetworkUsername = "testUser"
renderer.LoginCredentials.NetworkPassword = "testPassword"

pdf = renderer.RenderUrlAsPdf(url)
pdf.SaveAs("UrlToPdfExample2.Pdf")
pip install ironpdf
Website & System Logins

Website & System Logins

IronPDF for Python can render web pages that sit behind HTTP Basic Authentication by supplying login credentials directly to the renderer.

Getting Started

Create a ChromePdfRenderer and assign a ChromeHttpLoginCredentials object to its LoginCredentials property before calling RenderUrlAsPdf. IronPDF will include the credentials in the HTTP request used to fetch the page.

Understanding the Code

  • ChromeHttpLoginCredentials: Holds the username and password used for HTTP Basic Authentication.
  • LoginCredentials.NetworkUsername: The username to authenticate with the server.
  • LoginCredentials.NetworkPassword: The corresponding password.
  • RenderUrlAsPdf(url): Fetches the URL with the supplied credentials and renders the resulting page as a PDF.

Additional Rendering Options in This Example

The example also configures several RenderingOptions properties before rendering:

  • MarginTop / MarginBottom: Sets page margins in millimeters.
  • TextHeader / TextFooter: Adds text-based headers and footers with dynamic fields such as {pdf-title}, {date}, {time}, {page}, and {total-pages}.
  • CssMediaType: Set to Print so print-specific CSS rules are applied.

Use Cases

Supplying login credentials is useful when rendering internal dashboards, intranet pages, staging environments, or any URL protected by HTTP Basic Auth that your application needs to export as a PDF.

Learn to convert HTML to PDF with IronPDF for Python!

Ready to Get Started?

Version: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
Python Module Download for PDF
Install with pip

Version: 2026.9

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.9

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

Licenses from $999