Skip to content

Instantly share code, notes, and snippets.

@uhop
Last active November 29, 2022 23:35
Show Gist options
  • Save uhop/b145ca16959917ee673caa21e032bf79 to your computer and use it in GitHub Desktop.
Save uhop/b145ca16959917ee673caa21e032bf79 to your computer and use it in GitHub Desktop.
The way to print slides as PDF.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Multi-page print test</title>
<!--
Print to PDF, landscape, letter size, no margins, enable background graphics.
Tested on Chrome.
-->
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
.page {
page-break-inside: avoid;
break-inside: avoid;
page-break-before: always;
break-before: page;
background-image: radial-gradient(circle at 50% 50%, #00c 0%, #002 100%);
color: white;
padding: 1em;
height: 95%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.page:first-child {
page-break-before: avoid;
break-before: avoid;
}
</style>
</head>
<body>
<div class="page">
<h1>Slide 1</h1>
<p>Slide text.</p>
</div>
<div class="page">
<h1>Slide 2</h1>
<p>Slide text.</p>
</div>
<div class="page">
<h1>Slide 3</h1>
<p>Slide text.</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment