Output a standard Base64 Encoded stream into PDF format (PHP)

前端 未结 1 358
误落风尘
误落风尘 2021-01-23 18:12

I am using the Royal Mail Shipping API to generate printed PDF labels, my PHP SoapClient returns a valid response shown below (only shown the initial response as the whole respo

相关标签:
1条回答
  • 2021-01-23 18:52

    Sorted - been a very long day.

    I didn't need to decode the response in the end so the following will work (hopefully it helps someone else doing the API integration)

    function PrintLabelRequest($shipmentNumber, $transactionId)
    {
       $rm = new RoyalMailLabelRequest();
    
       // function from library returns a response using SOAP
       $response = $rm->PrintLabel($shipmentNumber, $transactionId);
    
       // name the file & saved this label as a PDF in the following folder
       $filename = 'printedlabel-' . $shipmentNumber;
       file_put_contents(dirname(__FILE__) . '/labels/'. $filename .'.pdf', $response);
    }
    
    0 讨论(0)
提交回复
热议问题