Dynamic content in django template

徘徊边缘 提交于 2019-12-24 23:25:07

问题


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">&nbsp;</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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!