Can WeasyPrint fit to Paper Size Automatically

css, html, pdf, python, weasyprint

Solution

By looking around for some ideas to format the pdf rendered by weasyprint, I found this question which might answer your question.

@page {
            size: Letter;
            margin: 0in 0.44in 0.2in 0.44in;
    }

WeasyPrint page size wrong. (8.27in x 11.69 in)

Problem

I used to work for an organization that used Prince XML to generate PDF's of HTML documents. That organization has since folded, and I no longer have access to that Prince license. Since I don't have four grand between the couch cushions, I've been attempting to use WeasyPrint to render HTML invoices to PDF. My HTML & CSS are both quite simple, so Weasy has no problem rendering them accurately, with on caveat. I cannot get the page to scale down automatically to the paper size like I could in prince using: ``` @page { prince-shrink-to-fit:auto; } ``` Does anyone know if Weasy supports any similar command before I rework the CSS of the entire site to generate smaller documents?

Original source

Related problems