JeremyDunn / php-fedex-api-wrapper

This library provides a fluid interface for constructing requests to the FedEx web service API.
269 stars 184 forks source link

PNG Label #74

Closed abnoy closed 5 years ago

abnoy commented 6 years ago

I'm having trouble retrieving a label as a PNG. PDF and ZPLII work fine but the response is blank when I use PNG.

I'm using the example in: https://github.com/JeremyDunn/php-fedex-api-wrapper/blob/master/examples/ship.php#L75

<?php
$labelSpecification = new ComplexType\LabelSpecification();
$labelSpecification
    ->setLabelStockType(new SimpleType\LabelStockType(SimpleType\LabelStockType::_PAPER_4X6))
    ->setImageType(new SimpleType\ShippingDocumentImageType(SimpleType\ShippingDocumentImageType::_PNG))
    ->setLabelFormatType(new SimpleType\LabelFormatType(SimpleType\LabelFormatType::_COMMON2D));
abnoy commented 6 years ago

Found the issue, the image isn't being returned as a Base64 encoded image. Is there a setting for this library to not decode the image? Wouldn't a Base64 encoded image in the return be desirable?

JeremyDunn commented 5 years ago

No setting, this is what the FedEx web service returns. Just file_put_contents() the image data itself.

Here's an example, but for a .pdf file.

https://github.com/JeremyDunn/php-fedex-api-wrapper/blob/master/examples/ship.php#L130-L131