Plugin Contributor
Ewout
(@pomegranate)
Hi! This is covered in the documentation here:
custom page size/orientation
Ewout
Thread Starter
Andrew
(@afedericojr)
Thank you for your reply, but I am using:
add_filter( 'wpo_wcpdf_paper_format', 'wcpdf_custom_inch_page_size', 10, 2 );
function wcpdf_custom_inch_page_size($paper_format, $template_type) {
// change the values below
$width = 9.5; //inches!
$height = 4.125; //inches!
//convert inches to points
$paper_format = array( 0, 0, $width * 72, $height * 72 );
return $paper_format;
}
…and somewhere there is a 1.5″ margin being added on. @page does not help, and even if I remove ALL CSS, the issue remains. It seems to still have it’s formatting for the 8.5 x 11 standard letter.
How can I specify a custom margin since I am printing for an envelope? At this point, I can’t get my return address to print because of it.
Additionally, I am looking to only affect the packing slip, but when I replaced the $template_type argument with ‘packing-slip’ it did not work. Do you have any suggestions?
Thank you
-
This reply was modified 9 years, 2 months ago by
Andrew.
Plugin Contributor
Ewout
(@pomegranate)
Hello Andrew,
The page size can only be altered with that filter, @page does does indeed not help here.
To change the margin, you will actually need to override the @page definition in the CSS. You may need to add !important to the definition.
To only make this affect the packing slip, you can use the very first example from the documentation (adapted to your size):
add_filter( 'wpo_wcpdf_paper_format', 'wcpdf_a5_packing_slips', 10, 2 );
function wcpdf_a5_packing_slips($paper_format, $template_type) {
if ($template_type == 'packing-slip') {
// change the values below
$width = 9.5; //inches!
$height = 4.125; //inches!
//convert inches to points
$paper_format = array( 0, 0, $width * 72, $height * 72 );
}
return $paper_format;
}
Good luck!
Ewout
Hello, I am using WooCommerce PDF Invoices & Packing Slips this plugin and want to change size of paper … I added this filter in my function.php but no change in paper size.
add_filter( ‘wpo_wcpdf_paper_format’, ‘wcpdf_custom_mm_page_size’, 10, 2 );
function wcpdf_custom_mm_page_size($paper_format, $template_type) {
// change the values below
$width = 150; //mm!
$height = 300; //mm!
//convert mm to points
$paper_format = array( 0, 0, ($width/25.4) * 72, ($height/25.4) * 72 );
return $paper_format;
}
Plugin Contributor
Ewout
(@pomegranate)
No change in the output or no change in the settings? This only changes the PDF media format, doesn’t add an option to the settings. Works for me!
Note that the size shown here (150x300mm) is not very different from the default A4 size (190x297mm)) – what’s your desired size?