How to Generate PDFs from Authenticated Pages

Learn how to generate PDFs from login-protected or authenticated pages during HTML to PDF conversion.

Overview

This guide explains how to use our HTML to PDF API to generate PDFs from pages that require Basic Authentication.

Get started example

In this example, we will generate a PDF from a protected URL. The API first authenticates against the target page and then renders it as a PDF.

  • url: The URL of the page you want to convert.
  • authentication: Authentication object that contains the following parameters.
  • authentication.username: The username used to authenticate.
  • authentication.password: The password used during authentication.
CURL
copy-integration-source-code-icon

Additional Notes

When converting authenticated pages, you must use the url parameter. Authentication parameters are not applied when converting raw HTML content.

If your application uses more complex authentication flows (such as session cookies, tokens, or SSO), you may need to use request headers instead.

For a full list of supported options, see the HTML to PDF API Reference.