问题
I have a Django application where using wkhtmltopdf I generate a pdf document. I have a section there, like the code below. I want to on each side was exactly 4 texts (objects). But everyone is different and the text comes out uneven arrangement. CSS does not help. How to do it?
The problem occurs when sections of text are of different sizes, in the generated PDF document. Sometimes everything is ok, because the number of texts fit on the page, and the rest goes to the next. And sometimes the text is cut off in the middle or a big gap at the top, in the next page.
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:50px;">
<h3>{% trans 'In progress' %}</h3>
{% for worked_on in worker.worked_on.all %}
<tr>
<td width="33%" align="left" valign="top"> </td>
<td width="67%" class="project-name">
//CONTENT
</td>
</tr>
<tr>
<td class="project-image" width="33%" align="left" valign="top">
//CONTENT
</td>
<td class="project-description" valign="top">
//CONTENT
</td>
</tr>
{% if forloop.counter|divisibleby:"4" %}
<tr>
<td class="project-description" style="margin-bottom:80px;">
<div style="page-break-after: always;"></div>
</td>
</tr>
{% endif %}
{% endfor %}
</table>
来源:https://stackoverflow.com/questions/29076271/dynamic-content-in-django-template