title: DHL ship label creation through PHP cUrl is not working
body: <p>I want to create shipping label (in pdf) via DHL. So, I have created the required xml format and post the same through PHP cUrl.</p>
  
  <pre><code>$message_ref = '';
  for ($i=0; $i&lt; 30; $i++)
  {
      $message_ref .= rand(0, 9);
  
  }   
  $message_time = date("Y-m-d") . "T" . date("H:i:sP");
  </code></pre>
  
  <p>Below is the <strong>codes</strong> for the XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;req:ShipmentValidateRequest xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com ship-val-req.xsd"&gt;
  &lt;Request&gt;
  &lt;ServiceHeader&gt;
  &lt;MessageTime&gt;$message_time&lt;/MessageTime&gt;
  &lt;MessageReference&gt;$message_ref&lt;/MessageReference&gt;
  &lt;SiteID&gt;XXXXX&lt;/SiteID&gt;
  &lt;Password&gt;XXXXX&lt;/Password&gt;
  &lt;/ServiceHeader&gt;
  &lt;/Request&gt;
  &lt;RequestedPickupTime&gt;N&lt;/RequestedPickupTime&gt;
  &lt;NewShipper&gt;N&lt;/NewShipper&gt;
  &lt;LanguageCode&gt;en&lt;/LanguageCode&gt;
  &lt;PiecesEnabled&gt;Y&lt;/PiecesEnabled&gt;
  &lt;Billing&gt;
  &lt;ShipperAccountNumber&gt;XXXXX&lt;/ShipperAccountNumber&gt;
  &lt;ShippingPaymentType&gt;S&lt;/ShippingPaymentType&gt;
  &lt;BillingAccountNumber&gt;XXXXX&lt;/BillingAccountNumber&gt;
  &lt;DutyPaymentType&gt;R&lt;/DutyPaymentType&gt;
  &lt;/Billing&gt;
  &lt;Consignee&gt;
  &lt;CompanyName&gt;-&lt;/CompanyName&gt;
  &lt;AddressLine&gt;Address 1 &lt;/AddressLine&gt;
  &lt;City&gt;Enugu&lt;/City&gt;
  &lt;Division&gt;Enugu&lt;/Division&gt;
  &lt;DivisionCode&gt;EN&lt;/DivisionCode&gt;
  &lt;PostalCode&gt;&lt;/PostalCode&gt;
  &lt;CountryCode&gt;NG&lt;/CountryCode&gt;
  &lt;CountryName&gt;Nigeria&lt;/CountryName&gt;
  &lt;Contact&gt;
  &lt;PersonName&gt;DDDDDD&lt;/PersonName&gt;
  &lt;PhoneNumber&gt;+23555555555&lt;/PhoneNumber&gt;
  &lt;PhoneExtension&gt;&lt;/PhoneExtension&gt;
  &lt;/Contact&gt;
  &lt;/Consignee&gt;
  &lt;Dutiable&gt;
  &lt;DeclaredValue&gt;0.00&lt;/DeclaredValue&gt;
  &lt;DeclaredCurrency&gt;USD&lt;/DeclaredCurrency&gt;
  &lt;TermsOfTrade&gt;DAP&lt;/TermsOfTrade&gt;
  &lt;/Dutiable&gt;
  &lt;Reference&gt;
  &lt;ReferenceID&gt;129624&lt;/ReferenceID&gt;
  &lt;ReferenceType&gt;St&lt;/ReferenceType&gt;
  &lt;/Reference&gt;
  &lt;ShipmentDetails&gt;
  &lt;NumberOfPieces&gt;1&lt;/NumberOfPieces&gt;
  &lt;Pieces&gt;&lt;Piece&gt;
  &lt;PieceID&gt;1&lt;/PieceID&gt;
  &lt;PackageType&gt;EE&lt;/PackageType&gt;
  &lt;Weight&gt;1&lt;/Weight&gt;
  &lt;DimWeight&gt;1&lt;/DimWeight&gt;
  &lt;Width&gt;1&lt;/Width&gt;
  &lt;Height&gt;1&lt;/Height&gt;
  &lt;Depth&gt;1&lt;/Depth&gt;
  &lt;PieceContents&gt;&lt;/PieceContents&gt;
  &lt;/Piece&gt;&lt;/Pieces&gt;
  &lt;Weight&gt;1&lt;/Weight&gt;
  &lt;WeightUnit&gt;L&lt;/WeightUnit&gt;
  &lt;GlobalProductCode&gt;P&lt;/GlobalProductCode&gt;
  &lt;Date&gt;2018-06-22&lt;/Date&gt;
  &lt;Contents&gt;SHIPMENT #129624&lt;/Contents&gt;
  &lt;DoorTo&gt;DD&lt;/DoorTo&gt;
  &lt;DimensionUnit&gt;I&lt;/DimensionUnit&gt;
  &lt;PackageType&gt;EE&lt;/PackageType&gt;
  &lt;IsDutiable&gt;N&lt;/IsDutiable&gt;
  &lt;CurrencyCode&gt;USD&lt;/CurrencyCode&gt;
  &lt;/ShipmentDetails&gt;
  &lt;Shipper&gt;
  &lt;ShipperID&gt;XXXXXX&lt;/ShipperID&gt;
  &lt;CompanyName&gt;CompanyName&lt;/CompanyName&gt;
  &lt;RegisteredAccount&gt;848XXXX&lt;/RegisteredAccount&gt;
  &lt;AddressLine&gt;MyAddress &lt;/AddressLine&gt;
  &lt;City&gt;Houston&lt;/City&gt;
  &lt;Division&gt;Texas&lt;/Division&gt;
  &lt;DivisionCode&gt;TX&lt;/DivisionCode&gt;
  &lt;PostalCode&gt;77031&lt;/PostalCode&gt;
  &lt;CountryCode&gt;US&lt;/CountryCode&gt;
  &lt;CountryName&gt;United States&lt;/CountryName&gt;
  &lt;Contact&gt;
  &lt;PersonName&gt;Urama&lt;/PersonName&gt;
  &lt;PhoneNumber&gt;65656565&lt;/PhoneNumber&gt;
  &lt;PhoneExtension&gt;&lt;/PhoneExtension&gt;
  &lt;/Contact&gt;
  &lt;/Shipper&gt;
  &lt;EProcShip&gt;N&lt;/EProcShip&gt;
  &lt;LabelImageFormat&gt;PDF&lt;/LabelImageFormat&gt;
  &lt;RequestArchiveDoc&gt;Y&lt;/RequestArchiveDoc&gt;
  &lt;Label&gt;
  &lt;LabelTemplate&gt;8X4_thermal&lt;/LabelTemplate&gt;
  &lt;Logo&gt;Y&lt;/Logo&gt;
  &lt;Resolution&gt;200&lt;/Resolution&gt;
  &lt;/Label&gt;
  &lt;/req:ShipmentValidateRequest&gt;
  </code></pre>
  
  <p>Below is the cUrl code:</p>
  
  <pre><code>$url = "https://xmlpi-ea.dhl.com/XMLShippingServlet";
  </code></pre>
  
  <p><strong>Modified</strong> ---</p>
  
  <pre><code>$ch = curl_init($url);
              curl_setopt($ch, CURLOPT_MUTE, 1);
              curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
              curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
              curl_setopt($ch, CURLOPT_POST, 1);
              curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
              curl_setopt($ch, CURLOPT_POSTFIELDS, "$query");
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
              $output = curl_exec($ch);
              curl_close($ch);
  #print_r($output);
  
  preg_match("/&lt;OutputImage&gt;(.*?)&lt;\/OutputImage&gt;/", $output, $matches);
     $image = base64_decode($matches[1]);
  
  &lt;img src="data:image/gif;base64,&lt;?=$image?&gt;"&gt;
  </code></pre>
  
  <p>Now I see the image is showing garbage chars in the browser. I have append "data:image/gif;base64," before $image but still garbage characters are showing. Can someone help me how can I display the image?</p>