Click or drag to resize
Pdf Library for .NET

Media Types

Many web pages define different sets of css styles for browser viewing (@media screen) and for printing (@media print). Select.Pdf Html to Pdf Converter for .NET can take advantage of this and generate the pdf using the specified media type.

Media type can be set using the CssMediaType property of the HtmlToPdfOptions object. The default value is Screen. The other possible value is Print.

Sample Code

This sample code shows how to convert an url to pdf using Select.Pdf Pdf Library for .NET and also use a media type during the conversion.

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

// set css @media print
converter.Options.CssMediaType = HtmlToPdfCssMediaType.Print;

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