How to print a pdf in a new tab? [migrated]
- by TheDuke777
I need to print a pdf by opening it in a new window. I've looked at tutorials for days, but nothing is working. I've tried many approaches, but this is the most recent:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function print()
{
window.getElementById("pdf").focus();
window.getElementById("pdf").print();
}
</script>
</head>
<body onload="print()">
<embed id="pdf" src="http://path/to/file" />
</body>
</html>
The page loads fine, with the pdf embedded. But it won't print, and I feel like I've been beating my head against a brick wall trying to figure this out. How can I get this to work? I'm willing to try anything at this point.