IRONSOFTWAREHOME
Website & System Logins

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.headerfooter.TextHeaderFooter;
import com.ironsoftware.ironpdf.render.ChromeHttpLoginCredentials;
import com.ironsoftware.ironpdf.render.ChromePdfRenderOptions;
import java.io.IOException;
import java.nio.file.Paths;

String url = "http://localhost:51169/Invoice";

ChromePdfRenderOptions renderOptions = new ChromePdfRenderOptions();
renderOptions.setMarginTop(50);
renderOptions.setMarginBottom(50);

// Set Login Credentials to bypass basic authentication
ChromeHttpLoginCredentials loginCredentials = new ChromeHttpLoginCredentials();
loginCredentials.setNetworkUsername("testUser");
loginCredentials.setNetworkPassword("testPassword");

try {
    PdfDocument webpage = PdfDocument.renderUrlAsPdf(url, loginCredentials);
    TextHeaderFooter textHeader = new TextHeaderFooter();
    textHeader.setCenterText("{pdf-title");
    textHeader.setDrawDividerLine(true);
    textHeader.setFontSize(16);
    webpage.addTextHeader(textHeader);

    TextHeaderFooter textFooter = new TextHeaderFooter();
    textFooter.setLeftText("{date} {time}");
    textFooter.setRightText("Page {page} of {total-pages}");
    textFooter.setDrawDividerLine(true);
    textFooter.setFontSize(14);
    webpage.addTextFooter(textFooter);
    
    webpage.saveAs(Paths.get("assets/UrlToPdfExample.pdf"));
} catch(IOException e) {
    e.printStackTrace();
}
mvn install
Website & System Logins

Website & System Logins

For rendering web pages located behind HTML forms and password-protected website directories into PDF files, the best practice is to forgo programmatic authentication and form submissions in favor of rendering the markup directly from local files or from HTML strings, as explained on the IronPDF login procedures resource page. However, in situations where accessing the source code of the web pages to be converted manually is cumbersome, time-intensive, or non-feasible, IronPDF can make rendering PDF content from these restricted areas easy and painless.

To convert web pages located behind password-protected directories, specify a set of valid network credentials for IronPdf's PDF Renderer to use with a ChromeHttpLoginCredentials object. Afterward, pass a reference to the ChromeHttpLoginCredentials along with the URL of the password-protected webpage to PdfDocument.renderUrlAsPdf.

Learn about ChromeHttpLoginCredentials for Java
View on GitHub

Ready to Get Started?

Version:2026.8just 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
Java Maven Library for PDF
Install with Maven

Version: 2026.8

<dependency>
   <groupId>com.ironsoftware</groupId>
   <artifactId>ironpdf</artifactId>
   <version>2026.8.2</version>
</dependency>
https://central.sonatype.com/artifact/com.ironsoftware/ironpdf/2026.8.2
or
Java PDF JAR
Download JAR

Version: 2026.8

Manually install into your project