Home
|
Contact
HOME
HTML to PDF
PDF TOOLS
DEMO
DOWNLOAD
BUY NOW
SUPPORT
HTML to PDF Library for .NET
EvoPdf Chromium for .NET
Cross-Platform
HTML to PDF for .NET
HTML to PDF for Java
HTML to PDF for Azure
HTML to PDF for UWP
HTML to PDF for Xamarin
HTML to PDF for Mono
HTML to PDF Converter
EvoPdf Chromium
HTML to Image Converter
HTML to SVG Converter
SVG to PDF Converter
Word to PDF Converter
Excel to PDF Converter
RTF to PDF Converter
PDF to Text Converter
PDF to Image Converter
PDF to HTML Converter
PDF Images Extractor
PDF Print
PDF Merge
PDF Split
PDF Security
PDF Viewer for ASP.NET
PDF Viewer for WinForms
Cross-Platform
PDF Library for .NET
HTML to PDF Converter Demo
EvoPdf Chromium Demo
Order Online
Licensing & Prices
License Renewal
License Agreement
Our Customers
HTML to PDF Converter User Guide
EvoPdf Chromium User Guide
Contact Support
Collapse
Expand
HTML to PDF Converter
Getting Started with HTML to PDF
HTML Content Destination and Scaling in PDF
Convert the Current HTML Page to PDF
Convert a HTML Page to PDF in Same Session
Merge Multiple HTML Pages into a Single PDF
Merge HTML with Existing PDF Documents
Partially Convert of a HTML Page to PDF
Repeat HTML Table Header and Footer in PDF
Headers and Footers
Page Breaks Control
Screen and Print Media Types
Use Different Styles for Screen and Print
Conversion Triggering Modes
Hierachical Bookmarks
Table of Contents
Live PDF Forms
HTML5 Features
HTTP GET and POST, Proxy Options
HTTP Headers and Cookies
Fonts Embedding
HTML Elements Location in PDF
HTML Elements Visibility in PDF
URI Links in PDF
Internal Links in PDF
File Links and Attachments
Text Notes in PDF
PDF Actions
HTML to PDF Elements
HTML to Image Elements
Images Quality in Generated PDF
Flash and Extensions Support
Watermarks and Stamps
PDF Background and Foreground
PDF/A and PDF/X Standards
CMYK and GrayScale Color Spaces
PDF Viewer Preferences
PDF Security Features
HTML to Image Converter
PDF Creator
PDF Editor
Live Demo
Description
Sample Code
Select Media Type When Converting HTML to PDF
EVO HTML to PDF Converter allows you to select the media type for which you want to render HTML to PDF. In this demo you can choose between rendering for screen or for print media types. The Full Description and a Code Sample can be accessed from the top tabs.
Convert HTML with @Media Rules
Convert URL or Local File
HTML String with @Media Rules
<!DOCTYPE html> <html> <head> <title>Media Type Rules</title> <style type="text/css"> /* Set the body text family and font size both for screen and print*/ body { width: 1000px; margin: 10px; font-family: 'Times New Roman'; font-size: 18px; } /* Set the title text font size and weight both for screen and print*/ .title { font-size: 24px; font-weight: bold; } @media screen { /* Set a background color only when the HTML page is displayed on screen*/ body { background-color: aliceblue; } /* Use blue to write the text on screen*/ p { color: darkblue; } } @media print { /* Hide images when priting*/ img { display: none; } /* Use black to write the text on screen*/ p { color: black; } } @media screen,print { /* Set the paragraph text family and font size both for screen and print*/ p { font-family: 'Times New Roman'; font-size: 20px; } } </style> </head> <body> <span class="title">Media Type Rules</span><br /> <br /> This document have different styles when it is displayed on the screen and when it is printed. You can instruct the converter to use the style you want setting its <i>MediaType</i> property.<br /> <br /> <b>The image below is visible only when the selected media type is 'screen' and is hidden when the selected media type is 'print'</b>:<br /> <br /> <img alt="Logo Image" src="img/logo.jpg" /> <br /> <br /> <b>The text below will be dark blue when the selected media type is 'screen' and black when the selected media type is 'print':</b> <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. </p> </body> </html>
Base URL
Select Media Type
Screen
Print