• Hello.
    When a customer enters a long note on our store (without using carriage returns) the PDF layout gets broken. All the “amounts” get pushed to the right, off screen.
    See here:
    https://tinyurl.com/yd5vhboz

    It is of course in Japanese.

    Any suggestions how to remedy this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @twd,

    What probably happens is that DomPDF doesn’t quite know how to wrap Japanese characters. You could try to hide the customer notes ( .customer-notes { display:none; } ) and then add them again with an action hook in your functions.php like this:

    
    add_action( 'wpo_wcpdf_after_order_details', 'wpo_wcpdf_show_shipping_notes', 10, 2 );
    function wpo_wcpdf_show_shipping_notes ($template_type, $order) {
        if ($template_type == 'invoice') {
            $document = wcpdf_get_document( $template_type, $order );
            ?>
    		<?php if ( $document->get_shipping_notes() ) : ?>
    			<h3><?php _e( 'Customer Notes', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
    			<p><?php $document->shipping_notes(); ?><p>
    		<?php endif; ?>
            <?php
        }
    }

    If you have never worked with actions hooks or functions.php before please read this guide: How to use filters

    With kind regards,

    Michael

    Thread Starter TWD

    (@twd)

    Thank you.
    Why would this fix the problem?
    Why is appending it via a custom function going to work?

    Plugin Contributor Ewout

    (@pomegranate)

    Sometimes dompdf (the external library we use to generate the PDF) is bit quirky when it comes to long texts in tables. What this method effectively does is moving the text out of the table and under the totals (instead of next to it). This may just be what dompdf needs to handle the wrapping better – but the proof is in the pudding ??
    Did you try the snippet?

    Thread Starter TWD

    (@twd)

    Unfortunately, this didn’t work.

    https://tinyurl.com/ydfdggqk

    Is the css “display:none;” command meant to hide it from the PDF invoice?
    It doesn’t seem to do so. I even added an !important command to the style instruction.

    Also, the custom function added the customer notes below the main invoice information as you can see but didn’t resolve the problem of not recognizing or inserting carriage returns into the customer notes field.

    Any other suggestions?

    Plugin Contributor Ewout

    (@pomegranate)

    I’m sorry to hear that.
    It’s a bit hard to tell whether this has worked since the original bit will stretch the whole canvas to the length of the text anyway.
    Where did you add the CSS? This is not regular theme/frontend CSS: Using custom styles.

    If you are using a custom template you could also remove the customer notes from invoice.php altogether, that’s this bit:

    
    <div class="customer-notes">
    	<?php do_action( 'wpo_wcpdf_before_customer_notes', $this->type, $this->order ); ?>
    	<?php if ( $this->get_shipping_notes() ) : ?>
    		<h3><?php _e( 'Customer Notes', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
    		<?php $this->shipping_notes(); ?>
    	<?php endif; ?>
    	<?php do_action( 'wpo_wcpdf_after_customer_notes', $this->type, $this->order ); ?>
    </div>
    

    Ewout

    Thread Starter TWD

    (@twd)

    I think we’ll just remove it from the PDF altogether.
    Where do I find invoice.php ?

    Plugin Contributor Ewout

    (@pomegranate)

    In the template folder. More information in the documentation: Creating a custom PDF template.

    Let us know if that helps!
    Ewout

    Thread Starter TWD

    (@twd)

    OK. that will do.

    Feature suggestion for future release:-
    Perhaps you should add a checkbox in the configuration options for “suppress customer comments on PDF invoice”.

    Any chance of that?

    Plugin Contributor kluver

    (@kluver)

    Hi @twd,

    To create a separate setting for this isn’t a priority right now because of the size of the issue. But we will definitely look into solving the issue all together in a future update.

    With kind regards,

    Michael

    Thread Starter TWD

    (@twd)

    OK thank you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Long Customer Notes break PDF layout’ is closed to new replies.