EVO HTML to PDF Converter

Convert HTML Pages with Authentication

EVO PDF Client for .NET Documentation

The web page you want to convert might be protected by different types of authentication. The most common authentication methods are Integrated Windows Authentication, Forms Authentication and custom Login pages. EVO HTML to PDF Converter offers support for resolving all these types of authentication.

Integrated Windows Authentication (NTLM)

The converter will automatically use the credentials of the user running the converter to resolve the NTLM authentication. This user can be the currently logged in user when using the converter in a desktop application or the user set as IIS pool identity when using the converter in an ASP.NET application. If the default automatic credentials cannot resolve the authentication you have the possibility to explicitly set the Username and Password in HtmlToPdfConverterAuthenticationOptions, HtmlToPdfElementAuthenticationOptions, HtmlToImageConverterAuthenticationOptions, HtmlToImageElementAuthenticationOptions or HtmlToSvgConverterAuthenticationOptions objects, function of the interface you are using to convert HTML to PDF or to images.

Code Sample - Explicitly Set the Authentication Options

C#
// Create the HTML to PDF converter
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
// Set authentication options
htmlToPdfConverter.AuthenticationOptions.Username = username;
htmlToPdfConverter.AuthenticationOptions.Password = password;

// Create a HTML to PDF element
HtmlToPdfElement htmlToPdfElement = new HtmlToPdfElement();
// Set authentication options
htmlToPdfElement.AuthenticationOptions.Username = username;
htmlToPdfElement.AuthenticationOptions.Password = password;

// Create the HTML to Image converter
HtmlToImageConverter htmlToImageConverter = new HtmlToImageConverter();
// Set authentication options
htmlToImageConverter.AuthenticationOptions.Username = username;
htmlToImageConverter.AuthenticationOptions.Password = password;

// Create a HTML to Image element
HtmlToImageElement htmlToImageElement = new HtmlToImageElement();
// Set authentication options
htmlToImageElement.AuthenticationOptions.Username = username;
htmlToImageElement.AuthenticationOptions.Password = password;

// Create the HTML to SVG converter
HtmlToSvgConverter htmlToSvgConverter = new HtmlToSvgConverter();
// Set authentication options
htmlToSvgConverter.AuthenticationOptions.Username = username;
htmlToSvgConverter.AuthenticationOptions.Password = password;
Cookie Based Authentication

The cookie based authentication implementation usually stores the forms authentication ticket in a cookie which should be sent back to server each time a resource is requested. The authentication cookies can be sent back to server using the HtmlToPdfConverterHttpRequestCookies, HtmlToPdfElementHttpRequestCookies, HtmlToImageConverterHttpRequestCookies, HtmlToImageElementHttpRequestCookies or HtmlToSvgConverterHttpRequestCookies properties, function of the interface you are using to convert HTML to PDF or to images.

Code Sample - Explicitly Set the Forms Authentication Cookie

C#
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();

// Add the authentication cookie to request
htmlToPdfConverter.HttpRequestCookies.Add(AuthCookieName, AuthCookieValue);

htmlToPdfConverter.ConvertUrl(urlToConvert);
Login Page Authentication

Authentication implemented at application level using a login page can be resolved by getting the HTML code of the web page to be converted and then convert that string to PDF.

The CSS files and images referenced by the HTML code to be converted should be placed in a location which doesn't require authentication or otherwise you'll have combine with one of the authentication methods above to resolve the resources.

See Also

Reference

Other Resources