Click or drag to resize
Pdf Library for .NET

Sending Parameters with a HTTP POST Request

By default, when a page is converted to PDF, SelectPdf performs a GET request for that page to obtain its content. SelectPdf Html To Pdf Converter for .NET can be used to send additional parameters to the web page that is converted using a HTTP POST request.

This can be done using the HttpPostParameters property of the HtmlToPdfOptions object.

Sample Code

This sample shows how to send parameters using a HTTP POST request to the page that will be converted using the html to pdf converter from SelectPdf Pdf Library for .NET.

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

// set the HTTP POST parameters
converter.Options.HttpPostParameters.Add(TxtName1.Text, TxtValue1.Text);
converter.Options.HttpPostParameters.Add(TxtName2.Text, TxtValue2.Text);
converter.Options.HttpPostParameters.Add(TxtName3.Text, TxtValue3.Text);
converter.Options.HttpPostParameters.Add(TxtName4.Text, TxtValue4.Text);

// 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