Skip to content

Instantly share code, notes, and snippets.

@zelitomas
Created October 17, 2021 11:52
Show Gist options
  • Save zelitomas/50aa47d4966e1b743588a284e12cf599 to your computer and use it in GitHub Desktop.
Save zelitomas/50aa47d4966e1b743588a284e12cf599 to your computer and use it in GitHub Desktop.
from weasyprint import HTML
document = HTML(filename="./index.html").render()
duplicated_pages = document.copy(document.pages * 2)
duplicated_pages.write_pdf("result.pdf")
<style>
html, body {
background-color: #ffeecc;
color: #0013ff;
font-family: "Neue Machina";
padding: 0;
margin: 0;
}
@page {
size: 64mm 37mm;
margin: 0;
}
#paper {
position: relative;
width: 64mm;
height: 37mm;
background-color: white;
border-radius: 2mm;
}
</style>
<div id="paper">
This should be printed twice, but is not.
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment