Click or drag to resize
Pdf Library for .NET

Accessing Web Pages through a Proxy with SelectPdf Library

Sometime a system is setup to be able to access the internet through a proxy. Select.Pdf Html to Pdf Converter supports this option and can convert web pages that can be accessed only though a proxy server.

To enable this feature the ProxyOptions property of the HtmlToPdfOptions object needs to be set. This is an instance of HtmlToPdfProxyOptions class that allows to set:

  • Proxy Host Name

  • Proxy Port Number

  • Username

  • Password

  • Proxy Type

Sample Code

This sample code shows how to convert an url to pdf using Select.Pdf Pdf Library for .NET and use a proxy to access the web page.

// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();

// set the proxy options
converter.Options.ProxyOptions.HostName = "proxy.server.name";
converter.Options.ProxyOptions.PortNumber = 1122;
converter.Options.ProxyOptions.Username = "proxyuser";
converter.Options.ProxyOptions.Password = "proxypassword";
converter.Options.ProxyOptions.Type = NetworkProxyType.Http;

// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl(TxtUrl.Text);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
See Also