You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.3 KiB

In [ ]:
from weasyprint import HTML, CSS
from weasyprint.fonts import FontConfiguration
In [ ]:
html = HTML(url="https://federicoponi.it")
font_config = FontConfiguration()
In [ ]:
css = CSS(string='''
@page{
        size: A4;
        margin: 15mm;
        background-color: white;
        font-family: monospace;
        font-size: 8pt;
        color: black;
            
        img{
        display:none;}
    }
    
    body{
        font-family: serif;
        font-size: 12pt;
        line-height: 1.4;
        color: black;
    }
    
    h1{
        width: 100%;
        text-align: center;
        font-size: 250%;
        line-height: 1.25;
        color: orange;
    }
    
    img{
        display:none;
    }
    
    #maxed responsive-img{
    display:none;
    }
    
    #submeta {
    display:none;
    }

''', font_config=font_config)
In [ ]:
html.write_pdf('mydocument.pdf', stylesheets=[css])
In [ ]: