Skip to content

Instantly share code, notes, and snippets.

@waylan
Created June 28, 2021 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waylan/cfff900b31e26c69bf02f0aa64263e02 to your computer and use it in GitHub Desktop.
Save waylan/cfff900b31e26c69bf02f0aa64263e02 to your computer and use it in GitHub Desktop.
from weasyprint import HTML
CONTENT = """
<html>
<head>
<style>
h1 {
padding: .5em 0;
background-color: lightskyblue;
}
ul {
columns: 4;
column-gap: normal; /*normal = 1em*/
list-style-type: none;
padding-left: 0;
}
</style>
</head>
<body>
<h1>Section Heading</h1>
<ul>
<li>Absolute Zero</li>
<li>Acid green</li>
<li>Aero</li>
<li>Aero blue</li>
<li>African violet</li>
<li>Air superiority blue</li>
<li>Alabaster</li>
<li>Alice blue</li>
<li>Alizarin</li>
<li>Alloy orange</li>
<li>Almond</li>
<li>Amaranth</li>
<li>Amaranth deep purple</li>
<li>Amaranth pink</li>
<li>Amaranth purple</li>
<li>Amaranth red</li>
<li>Amazon</li>
<li>Amber</li>
<li>Amethyst</li>
<li>Android green</li>
<li>Antique brass</li>
<li>Antique bronze</li>
<li>Antique fuchsia</li>
<li>Antique white</li>
<li>Ao (English)</li>
<li>Apple green</li>
<li>Apricot</li>
<li>Aqua</li>
<li>Aquamarine</li>
<li>Arctic lime</li>
<li>Army green</li>
<li>Artichoke</li>
<li>Arylide yellow</li>
<li>Ash grey</li>
<li>Asparagus</li>
<li>Atomic tangerine</li>
<li>Auburn</li>
<li>Aureolin</li>
<li>Avocado</li>
<li>Azure</li>
</ul>
</body>
</html>
"""
html = HTML(string=CONTENT)
html.write_pdf('columns.pdf')
@waylan
Copy link
Author

waylan commented Jun 28, 2021

Here is what the output looks like:

Untitled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment