A HTML document can define multiple styles to target different media types using the @media rules. For example, a document can have a style to be used when displaying the document in browser on a screen defined by a "@media screen" rule and a different style to be used when printing the HTML document defined by a "@media print".
The HTML to PDF converter can be instructed to render for a given media type using the PdfConverter..::..MediaType property. For example, in order to use the style for printing defined in the HTML document by the "@media print" rule, the PdfConverter..::..MediaType property must be set with "print" value.
This property is also defined in the other classes for HTML conversion: HtmlToPdfElement, ImgConverter and HtmlToImageElement.
Code Sample - Setting Media Type for Printing
| C# | |
|---|---|
// create the PDF converter PdfConverter pdfConverter = new PdfConverter(); // setup the media type for printing pdfConverter.MediaType = "print"; | |