Closed vkas002 closed 5 years ago
Do you get an error of any description?
No errors. In response, I am getting 4 different label PDF files and I am looking for all four in one PDF (This was working earlier for older version but not working for new API ).
fwrite($handle, $results->getMergedLabels()->getMergedLabel()->getLabels()->getLabel()->getContent());
In the above code I was getting 4 labels in one PDF using the Mergelabels attribute but now it contains NULL value.
Can you call $client->debug()
after the generateLabels call and share the output?
Although I think I already know. The return value of getLabel is an array (with a single Label object). PHP SoapClient supports directly returning the object if it's just one, but it's not desirable and thus it's disabled in 2.x. The new code should simply be:
fwrite($handle, $results->getMergedLabels()->getMergedLabel()->getLabels()->getLabel()[0]->getContent());
fwrite($handle, $results->getMergedLabels()->getMergedLabel()->getLabels()->getLabel()[0]->getContent());
This doesn't seems to be working because in response the MergedLabels attribute contains NULL value.
Below i have shared by response.
object(DivideBV\Postnl\ComplexTypes\GenerateLabelResponse)#247 (2) { ["MergedLabels":protected]=> NULL ["ResponseShipments":protected]=> object(DivideBV\Postnl\ComplexTypes\ArrayOfResponseShipment)#248 (1) { ["ResponseShipment":protected]=> array(4) { [0]=> object(DivideBV\Postnl\ComplexTypes\ResponseShipment)#249 (7) { ["Barcode":protected]=> string(13) "3STSRV5090232" ["DownPartnerBarcode":protected]=> NULL ["DownPartnerID":protected]=> NULL ["DownPartnerLocation":protected]=> NULL ["Labels":protected]=> object(DivideBV\Postnl\ComplexTypes\ArrayOfLabel)#250 (1) { ["Label":protected]=> array(1) { [0]=> object(DivideBV\Postnl\ComplexTypes\Label)#251 (3) { ["Content":protected]=> string(14096) "%PDF-1.2 1 0 obj PDF 1 file (I have removed the pdf output. Here i am getting a single label in a pdf) %%EOF " ["Contenttype":protected]=> NULL ["Labeltype":protected]=> string(5) "Label" } } } ["ProductCodeDelivery":protected]=> string(4) "4944" ["Warnings":protected]=> object(DivideBV\Postnl\ComplexTypes\ArrayOfWarning)#252 (1) { ["Warning":protected]=> NULL } } [1]=> object(DivideBV\Postnl\ComplexTypes\ResponseShipment)#253 (7) { ["Barcode":protected]=> string(13) "3STSRV2927219" ["DownPartnerBarcode":protected]=> NULL ["DownPartnerID":protected]=> NULL ["DownPartnerLocation":protected]=> NULL ["Labels":protected]=> object(DivideBV\Postnl\ComplexTypes\ArrayOfLabel)#254 (1) { ["Label":protected]=> array(1) { [0]=> object(DivideBV\Postnl\ComplexTypes\Label)#255 (3) { ["Content":protected]=> string(14061) "%PDF-1.2 1 0 obj PDF 2 file (I have removed the pdf output. Here i am getting a single label in a pdf) %%EOF " ["Contenttype":protected]=> NULL ["Labeltype":protected]=> string(5) "Label" } } } ["ProductCodeDelivery":protected]=> string(4) "4944" ["Warnings":protected]=> object(DivideBV\Postnl\ComplexTypes\ArrayOfWarning)#256 (1) { ["Warning":protected]=> NULL } } [2]=> object(DivideBV\Postnl\ComplexTypes\ResponseShipment)#257 (7) { ["Barcode":protected]=> string(15) "3STSRV901903677" ["DownPartnerBarcode":protected]=> NULL ["DownPartnerID":protected]=> NULL ["DownPartnerLocation":protected]=> NULL ["Labels":protected]=> object(DivideBV\Postnl\ComplexTypes\ArrayOfLabel)#258 (1) { ["Label":protected]=> array(1) { [0]=> object(DivideBV\Postnl\ComplexTypes\Label)#259 (3) { ["Content":protected]=> string(7141) "%PDF-1.2 1 0 obj PDF 3 file (I have removed the pdf output. Here i am getting a single label in a pdf) %%EOF " ["Contenttype":protected]=> NULL ["Labeltype":protected]=> string(5) "Label" } } } ["ProductCodeDelivery":protected]=> string(4) "3085" ["Warnings":protected]=> object(DivideBV\Postnl\ComplexTypes\ArrayOfWarning)#260 (1) { ["Warning":protected]=> NULL } } [3]=> object(DivideBV\Postnl\ComplexTypes\ResponseShipment)#261 (7) { ["Barcode":protected]=> string(15) "3STSRV434265636" ["DownPartnerBarcode":protected]=> NULL ["DownPartnerID":protected]=> NULL ["DownPartnerLocation":protected]=> NULL ["Labels":protected]=> object(DivideBV\Postnl\ComplexTypes\ArrayOfLabel)#262 (1) { ["Label":protected]=> array(1) { [0]=> object(DivideBV\Postnl\ComplexTypes\Label)#263 (3) { ["Content":protected]=> string(7150) "%PDF-1.2 1 0 obj PDF 4 file (I have removed the pdf output. Here i am getting a single label in a pdf) %%EOF
["Contenttype":protected]=>
NULL
["Labeltype":protected]=>
string(5) "Label"
}
}
}
["ProductCodeDelivery":protected]=>
string(4) "3085"
["Warnings":protected]=>
object(DivideBV\Postnl\ComplexTypes\ArrayOfWarning)#264 (1) {
["Warning":protected]=>
NULL
}
}
}
} }
Can you please post the raw XML, using $client->debug()
?
Sure. Below i have attached the raw xml.
Please be careful with personal information. You might want to remove that attachment now. The important bit is here:
You are not passing the correct printer type. Check here under "printer types". You can pass the printer type as the second argument to generateLabels
.
Also, depending on your type of printer, this may or may not work for you. We just used ghostscript to combine the separate labels into a single PDF, one each page.
I have set the PrinterType to "GraphicFile|PDF|MergeA" and it seems to be working now. Thanka alot man. Cheers!
Good to hear. You're welcome!
Hello,
I am using your POSTNL API for almost an year to generate multiple labels in a single page (Basically 4 labels in one pdf) which was working successfully. Recently I updated the code so that i can upgrade to the new POSTNL API. After updating the code (using the lastest vserion of DivideBV/Postnl ) i am not able to generate multiple column shipment labels.
Below i have shared code. Can you please tell me what is the issue? Thank you.