Created
October 31, 2019 00:45
-
-
Save fredgdaley2/2c89631157304fb1e2a32c856791b490 to your computer and use it in GitHub Desktop.
Print html to pdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<style> | |
.redhead { | |
color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="content"> | |
<h1 class="redhead">Hello World</h1> | |
<p>this is a PDF</p> | |
<input type="radio" name="gender" value="male"> Male<br> | |
<input type="radio" name="gender" value="female"> Female<br> | |
<input type="radio" name="gender" value="other" checked> Other | |
</div> | |
<script> | |
var win = window.open("", "Title", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=200,top=" + (screen.height - 400) + ",left=" + (screen.width - 840)); | |
win.document.head.innerHTML = document.head.innerHTML; | |
win.document.title = "John Smith Survey"; | |
win.document.body.innerHTML = document.body.innerHTML; | |
win.print(); | |
win.close(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment