3

Hi am generating PDF's from html template containing a table which number of rows vary, problem is when the rows are in excess of certain number(12) the rest of the rows plus the footer are pushed further below and don't appear in the generated pdf.How can I make it dynamic so that extra info is pushed to new page each having atleast a certain number of rows, or is there a way weasy print to move data to another page if the current is full

So far I have page breaks on the template but it has worked.

{% for record in data %}
    <tr>
        <td> {{ record.id}}</td>
        <td> {{ record.date}}</td>
    </tr>
    {% if forloop.counter|divisibleby:12 %}
        <div style="page-break-after: always;"></div>
        div style="page-break-before: always;"></div>
    {% endif %}
{% endfor %}
StackEdd
  • 624
  • 1
  • 10
  • 23
  • Are you seeing any table at all in your PDF? I've copied your markup and style and I can't, I can in HTML... – Adam Barnes Feb 02 '18 at 14:24
  • yes I can see the table,@AdamBarnes – StackEdd Feb 02 '18 at 14:27
  • Could you do me a favour and check out my [repo](https://github.com/Asday/weasyprint-pagination/tree/280b8c584f2ed04128b64edf09a6846e20aa5fa4) - now updated with your code, and let me know if you see the table in the PDF? I can only see it in the HTML and I'm wondering what's going on... – Adam Barnes Feb 02 '18 at 15:49
  • @AdamBarnes I cannot view the table too , not sure where the problem might be – StackEdd Feb 05 '18 at 10:17
  • Well then - your question has given me a question. :D – Adam Barnes Feb 05 '18 at 10:18

2 Answers2

5

Removed the body tags from my template and it worked without using page breaks, weasyprint limits everything in the body tag to be one document in a page. another answer that helped

StackEdd
  • 624
  • 1
  • 10
  • 23
1

I've thrown together a repo to try and reproduce your issue here, and was unable to.

There's a small syntax error in your question - you're missing the < off your second <div />, but apart from that, it all looks good.

Adam Barnes
  • 2,922
  • 21
  • 27