- HTML to PDF APIConvert HTML and URLs into PDFsExtract PDF Form Data APIEasily extract data from PDFsWatermark PDF APIAdd custom watermarks to PDFsProtect PDF APISecure your PDFs with passwordCompress PDF APIReduce file size without losing qualityFlatten PDF APIFlatten PDFs to make form permanentDigital Signature APISend documents for signing
- API DocumentationAPI DocumentationFull REST API referenceNodeJS SDKClient library for Node.jsJava SDKClient library for JavaC# SDKClient library for C#PHP SDKClient library for PHPPython SDKClient library for Python
- Pricing
- Contact Us
HTML to PDF
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.username: The username used to authenticate.authentication.password: The password used during authentication.
CURL
1curl --request POST \2 --url https://api.pdfgate.com/v1/generate/pdf \3 --header 'Authorization: Bearer YOUR_API_KEY' \4 --header 'Content-Type: application/json' \5 --data '{6 "url": "https://httpbin.org/basic-auth/user/passwd",7 "authentication": {8 "username": "user",9 "password": "passwd"10 }11 }' \12 -o output.pdfAdditional 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.