• Resolved volkerforster

    (@volkerforster)


    I have been using this plugin for a couple of years, and first, it always printed the entire block of sub-total, taxes, shipping and total on the same page. But a long time ago, it started breaking pages so weird that sometimes (depending on the order), only the last line is moved onto another page. Besides that, I cannot find out how to repeat the header (like customer name, shipping address, date and invoice number) on every page and to add a page counter to the footer (like “1 of 3”).
    Can you help with these concerns?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    I have been using this plugin for a couple of years, and first, it always printed the entire block of sub-total, taxes, shipping and total on the same page. But a long time ago, it started breaking pages so weird that sometimes (depending on the order), only the last line is moved onto another page.

    Could you please show me screenshots of the pages of a testing PDF document? You can use imgbb.com to upload the screenshots, and the share the images URLs here.

    Besides that, I cannot find out how to repeat the header (like customer name, shipping address, date and invoice number) on every page…

    You can read this article from the Docs to achieve it: Repeating headers & footers.

    …and to add a page counter to the footer (like “1 of 3”).

    This can be achieved in two ways:

    1. With a custom block, using the customizer included in Premium Templates, this way:

      A screenshot that displays a custom block with the page numbering setup

    2. With some PHP code, with a code snippet like this:
      /**
       * WooCommerce PDF Invoices & Packing Slips:
       * Add a page numbering on the invoices
       */
      add_action( 'wpo_wcpdf_after_document', function ( $document_type, $order ) {
      	if( $document_type == 'invoice' ) {
      		echo '<div style="position:fixed; left:0; bottom:-1cm; height: 1cm; width:100%">Page {{PAGE_NUM}} of {{PAGE_COUNT}}</div>';
      	}
      }, 10, 2 );

      If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Please note that repeating the headers & footers, and adding a page numbering to your documents, doesn’t work if you also want to print the invoices in bulk from the order list, as the footers of multiple invoices will stack on top of each other. This can be solved using the Bulk export feature included in the Professional extension.

    Thread Starter volkerforster

    (@volkerforster)

    Thank you so much for your support. The weird page breaks are gone after switching to a different theme with more features included, which in return enabled me to remove about 10 plugins. The problem was most likely caused by one of the plugins, the HELLO or re:hub Elementor theme.

    Thank you for the PHP code to include the pagination. I tried it, but as you already mentioned, it is not useful for me. I always print 15 invoices in bulk (not more to reduce server load). I hoped you could tell me how to print these invoices in single files rather than one large file, to be able to print double-sided and save paper. But you explained that your plugin only offers something like that when using Bulk Export. I will see find out if this is helpful for me.

    Thread Starter volkerforster

    (@volkerforster)

    Hi I need to modify my answer. The problem with the weird page breaks is NOT gone, and it was not related to another plugin. The glitch still exists. So annoying! And since I know that printing repeating headers and page numbers will also not work when bulk-printing invoices, I will look for an alternative. It does not look like you will fix these issues anytime soon.

    See the break page between page 7 and 8 in this bulk invoice file:
    universal-solder.ca/downloads/invoices-2022-08-22.pdf

    Thread Starter volkerforster

    (@volkerforster)

    Another addition: the weird pagebreak even happens when a single invoice is printed, not only when I print in bulk. I am sorry but it looked like it would work now, until I printed again a single invoice with only the last two lines of the summary block on a new page.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Sorry for the late reply, @volkerforster!

    See the break page between page 7 and 8 in this bulk invoice file

    Thanks for providing that example! I understand now what you meant. However, this is a normal behavior, when the document has reached the available space in the invoice. Maybe you would prefer to move the complete totals’ area to the next invoice, but that is also a challenge, and I’m not sure if you would be happy with that solution anyway.

    That said, let me ask you a question: Do you use this PDF document to print the invoices later, or just to have a digital archive of your invoices? If the latest, we could provide you with a code snippet that calculate the sheet height automatically, so you only see a page per invoice, although with different heights, based on the product quantity on the invoice. What do you think about this proposed solution?

    Edited: I read again your previous messages and realized that you indeed use the exported file to print the invoices. However, you could still provide me with one or more examples about how you expect the output, or totals’ area specifically, behaves when the order item table is quite long.

    • This reply was modified 2 years, 3 months ago by Yordan Soares. Reason: I realized that the answer was in a previous message
    Thread Starter volkerforster

    (@volkerforster)

    We print batches of 13 invoices, which will ship together with the orders.
    It would be a blessing if your plugin would:
    1. generate separate PDFs for every order, even if selected in bulk
    2. would add a page break before the totals block in case the block will not fit entirely in the page
    If your plugin could generate separate invoices instead of one large PDF file, even adding a repeating header, a page number to the footer, and double-sided printing would be possible. Maybe you can add a switch to the settings where the user can select bulk print into one or multiple files. This would resolve just all the problems at once.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    1. generate separate PDFs for every order, even if selected in bulk

    This is a feature already included in the Professional extension: Bulk export tool. It allows you to export PDF documents in a more granular way, as a zip or directly to Dropbox, as individual files. See Using the Bulk export tool

    2. would add a page break before the totals block in case the block will not fit entirely in the page

    I think this could be achieved with a trick: Setting a minimum height for the customer notes cell, which is equal to the space occupied by the total’s table.

    Try adding this code snippet to check if it worked:

    /**
     * WooCommerce PDF Invoices & Packing Slips:
     * Add a min-height to the customer notes to move the totals' area completely on page breaks
     */
    add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {	
    	if ( $document_type == 'invoice' ) {
    		?>
    		tr.no-borders .customer-notes {
    			background: red;
    			min-height: 2.5cm;
    		}
    		<?php
    	}
    }, 10, 2 );
    Thread Starter volkerforster

    (@volkerforster)

    Thank you for your reply. I will try your code another day. But it looks like the summary block is always printed completely on one page if the standard theme is selected. The problem with the ugly page breaks seems to be related to the “Simple Premium” that we are using.

    You said “This is a feature already included in the Professional extension: Bulk export tool. It allows you to export PDF documents in a more granular way, as a zip or directly to Dropbox, as individual files. See Using the Bulk export tool”.

    Unfortunately, this is not an acceptable workaround (for us). We select invoices from the WooCommerce order list, and print from there. This is our procedure, and we have reasons not to use a cumbersome workaround like filling out a filter for exports, exporting to somewhere, opening the file etc. WAY too difficult.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I will try your code another day. But it looks like the summary block is always printed completely on one page if the standard theme is selected. The problem with the ugly page breaks seems to be related to the “Simple Premium” that we are using.

    Please note that the code snippet I wrote above is intended to be used with Simple template. The Simple Premium has a different layout than our default Simple template, that also has a limited compatibility with the customizer.

    However, since you have Premium Templates, you can write us at [email protected], so we can provide you with premium support ??

    Unfortunately, this is not an acceptable workaround (for us). We select invoices from the WooCommerce order list, and print from there. This is our procedure, and we have reasons not to use a cumbersome workaround like filling out a filter for exports, exporting to somewhere, opening the file etc. WAY too difficult.

    I completely understand. I think that a code snippet like the one above, but intended to be used with Simple Premium, might work. I’ll be looking for your message at [email protected]

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘weird page breaks’ is closed to new replies.