First of all, copying files that can just be overridden from the Core to Local is not best practise as it can possibly give you more work when upgrading Magento.
I have tested your case and found your solution:
First of all I rewrite it in my own extension:
<models>
<sales>
<rewrite><order_pdf_items_invoice_default>MycompanyName_Myextensionname_Model_Order_Pdf_Items_Invoice_Default</order_pdf_items_invoice_default></rewrite>
</sales>
</models>
Then I override the function you mentioned above:
$options = $this->getItemOptions();
if ($options) {
foreach ($options as $option) {
if ($option['value']) {
if (isset($option['print_value'])) {
$_printValue = $option['print_value'];
} else {
$_printValue = strip_tags($option['value']);
}
$values = explode(', ', $_printValue);
foreach ($values as $value) {
$lines[][] = array(
'text' => Mage::helper('core/string')->str_split(strip_tags($option['label'] . " - " . $value), 40, true, true),
'feed' => 40
);
}
}
}
}
What I have done here is just removed the part where you draw the label and added it to the part where you print the value.
If you have long labels/values and you want to keep it on one line, I would increase the value in str_split.
Best Answer
I don't think there is something "out-of-the-box" in Magento 2 for this. But you can easily create an observer for the event
sales_order_invoice_register
. This event is called after a new invoice is created. You can realize that with something like this:1. register observer in events.xml
2. create YourObserver.php