how get labels multi collo shipment
Closed this issue · 2 comments
matthijs-neijenhuijs commented
How can i get the labels. This is working:
https://github.com/DivideBV/Postnl/wiki/Multi-collo-shipment
But what do need to do to get the labels? You cannot get it from GenerateLabelResponse.
I can get the labels deeper: $result->getResponseShipments()->getResponseShipment() but i want to have a MergedLabel.
slokhorst commented
Get a mergedLabel like so (note that you need to specify 'GraphicFile|PDF|Merge'
in the generateLabels
call):
$result = $client->generateLabels(new ComplexTypes\ArrayOfShipment([$shipment1,$shipment2]), 'GraphicFile|PDF|Merge');
$i = 0;
foreach($result->getMergedLabels() as $mergedLabel){
foreach($mergedLabel->getLabels() as $label) {
$filename = "label_$i.pdf";
$file = new \SplFileObject($filename, 'w');
$file->fwrite($label->getContent());
$file = null; //close file
$i++;
}
}
It should only return one label file, but I've put it in a loop to be sure.
matthijs-neijenhuijs commented
Thnx! didn't now there was a second parameter :-) Stupid