although I just don't have the need to ask something normally (internet is just a gold mine, especially this site), this is getting me off, as I had been two days trying to get this working and I don't find anything useful. Link for similar post would be thanked if founded, as I didn't found one. Let's get started.
I'm using PDFKit with Python 2.7 and Django 1.9 to generate some HTML to PDF. Easy work. The HTML just looks like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
* {
/* Box-model */
margin: 0;
padding: 0;
}
.wrapper {
/* Box-model */
width: 229mm;
height: 161mm;
}
</style>
</head>
<body>
{% for someone in people %}
<div class="wrapper">
<p><strong>{{ someone.complete_name }}</strong></p>
<p>{{ someone.bio }}</p>
</div>
{% endfor %}
</body>
</html>
My PDFKit options looks like this:
{
"page-width": "229mm",
"page-height": "162mm",
"paper-size": "CE5",
"encoding": "utf-8"
}
In both cases I just don't add any margins or paddings. I generate the PDF, and looks great (no surprises, all goes where it belongs). But, if I add any margin/padding in the HTML and/or options, I just get a continued repetitive incremental margin when the PDF is generated (to give an example, in 50 pages, the first one has no margin, and the 50th has a margin of about two fingers more or less). I tried different combinations of margins, paddings and heights and nothing: when I just add margins or paddings, the PDF gets crazy.
(Note: yeah, page-height is 1mm larger than height in HTML, but that is needed so the wrapper fits in the PDF page).
Anyone had meet this problem before? Thanks in advance.