Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Unnecessary Page Break After Addresses on Invoice

  • Resolved linux4me2


    I’m using WP 5.1 and version 2.2.7 of the plugin. The PDF invoices for two of the ten orders since upgrading to this version have a page break right after the addresses on the invoice, then the product detail section starts on the second page. That means there’s a huge amount of white space on page one of the invoices.

    The only thing different about these two invoices as compared to the ones that don’t have the unnecessary page break is the number of products in the orders. Both these invoices have seven products. It looks like that many products might be just barely too much to fit on one page, but instead of putting a page break within the product list, it adds a page break and starts on page two. The invoices that come out correctly have fewer products and all fit on one page. Unfortunately, I don’t have any orders with more than seven products to see if there’s a point where the page break is inserted within the product list.

    The interesting thing is that the packing slips are unaffected, but I believe that’s because they don’t have the additional subtotal, shipping, tax, and total lines, and thus fit on one page nicely.

    There are no errors in the error log, and everything else seems to be working just fine. Everything is green on my Status page except for opcache, which we don’t use. It looks like this is an issue with the page formatting and the PDF creation, but I haven’t been able to find the source.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Ewout


    Hi! The regular Simple template actually does allow page breaks in the order items table, I just tested this to confirm:

    Did you make any changes to the template or template styles?

    I am using the default templates and haven’t made any changes.

    Yes, the page breaks seem to work fine in most cases. In fact, I tried duplicating the issue on a test site using the same logo and display options and couldn’t. I compared the problem site’s settings and they’re identical, though the products are different. I also deleted legacy settings just in case, but it didn’t make a difference. By the way, I’ve had the Test box checked so I’m regenerating the invoice with current settings when testing.

    It seems that the problem only occurs when the output is a certain length. In both affected invoices, the customer address section was six lines long, and the product detail was just a little longer than the remaining space on the page with a footer to my eye.

    Is there anything else I can try to troubleshoot this?

    Plugin Support kluver


    Hi @linux4me2,

    It could be the case that the product description is so long that it doesn’t fit between the header and the footer. A page break is created between products when the product table becomes too large. Not in the middle of a product. So when there is a lot of data there it might jump to the next page completely.

    Could you send us a screenshot of a document where this is going wrong?

    It does seem like it has to do with the length of the product section. I temporarily switched from Letter to A4, and the invoices were able to fit the entire product section on one page.

    Here’s a screenshot of one of the affected invoices:

    • This reply was modified 6 months, 2 weeks ago by  linux4me2. Reason: fix the screenshot link
    Plugin Support kluver


    Hi @linux4me2,

    Looking at your screenshot the amount of data per item isn’t that much. Can you try setting the bottom margin of the order details table to zero and see if that has any effect? You can use the following code snippet:

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles' );
    function wpo_wcpdf_custom_styles () {
    	table.order-details {
    	    margin-bottom: 0mm;

    This snippet should be placed in the functions.php of your child theme. If you haven’t worked with code snippets or functions.php before please read this: How to use filters

    Hi @kluver,

    Thanks! That code snippet changing the bottom margin fixed the issue on both invoices, so that now the Product section appears right below the addresses and all of the product section fits on one page.

    Is that a troubleshooting step, or a permanent fix?

    Plugin Author Ewout


    Hi! This appears to be a bug in the PDF renderer (dompdf, which is an external library), and our hypothesis was that the page break logic did not take the margins of the table into account. It’s a bit hard to reproduce because it’s so specific in size of all the elements on the page (I’ve never seen this myself and like you also said, page breaks work fine most of the time when the contents don’t fit the page)… But if this fixes it, it’s possible that our hypothesis is correct – until falsified. So if you can still reproduce the issue even without the bottom margin, let us know! I’m marking this solved for now.

    Your hypothesis makes sense to me, and is consistent with behavior I’ve experienced with another PDF renderer (FPDF).

    If it happens again with the bottom margin set to zero, I will post back here. It’s rare that we have more products purchased in an order than will fit on one page, and even then, hitting the specific size that triggers the bug is apparently not easy.
    I still haven’t been able to reproduce it on the test site.

    Thanks for your help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Unnecessary Page Break After Addresses on Invoice’ is closed to new replies.