Hi! Since PDF is a static media size, you can’t really make it responsive, but you can probably get close with the filter that controls the media size, wpo_wcpdf_paper_format
. This filter did not get any order information until now (9486819), so you will either need to download the latest version from github, or wait until the next release (early next week if everything goes to plan).
With this updated version you can use this filter (tweaking the parameters for your setup) to change the height based on the number of items:
add_filter( 'wpo_wcpdf_paper_format', 'wpo_wcpdf_paper_format_dynamic', 10, 3 );
function wpo_wcpdf_paper_format_dynamic( $paper_format, $document_type, $document = null ) {
if (!empty($document) && !empty($document->order)) {
$order_items = $document->order->get_items();
$item_count = count($items);
// do your magic with the $item_count here, below example is all sizes in mm:
$width = 150;
$height = 150+40*$item_count;
//convert mm to points
$paper_format = array( 0, 0, ($width/25.4) * 72, ($height/25.4) * 72 );
}
return $paper_format;
}
What code are you currently using for the order time?