• Hi,

    I have followed your instruction to change the packing list to 4×6 label with the following code.

    add_filter( 'wpo_wcpdf_paper_format', 'wcpdf_custom_inch_page_size', 10, 2 );
    function wcpdf_custom_inch_page_size($paper_format, $template_type) {
        if ($template_type == 'packing-slip') {
    	    // change the values below
    	    $width = 4; //inches!
    	    $height = 6; //inches!
    	 
    	    //convert inches to points
    	    $paper_format = array( 0, 0, $width * 72, $height * 72 );
        }
        return $paper_format;
    }

    How do I adjust the margin of packing list? I tried the following code but it is still following the setting in style.css file.

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) {
          $document = wcpdf_get_document( $template_type, $order );
          if ($template_type == 'packing-slip') {
            ?>
                td.header img {
                    max-height: 0.25cm;
                    width: auto;
                }
    
                @page {
                    margin-top: 0.1cm;
                    margin-bottom: 0.1cm;
                    margin-left: 0.1cm;
                    margin-right: 0.1cm;
                }
    
                <?php
        }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @ridgegate

    You had a bug in your second code snippet, please try this instead:

    add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
    	if ($document_type == 'packing-slip') {
    	?>
    		td.header img {
    			max-height: 0.25cm;
    			width: auto;
    		}
    
    		@page {
    			margin-top: 0.1cm;
    			margin-bottom: 0.1cm;
    			margin-left: 0.1cm;
    			margin-right: 0.1cm;
    		}
    
    		<?php
    	}
    }, 10, 2 );
    Thread Starter ridgegate

    (@ridgegate)

    Hi Alex,

    Thank you! it works.

    Tom

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change Margin for Packing List’ is closed to new replies.