2

I am trying to create a packing slip for delhivery. An APi from delhivery send the details of packing slip including the Barcode source.

$barcodeImage = data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMYAAAB4CAIAAAAmORoPAAANl0lEQVR4nO3afUwTdxgH8Dsob8qbxQJOeRGYvPkyShBUCoGiDLcpDBgFtolMGImL4nQzMGP2EkA2ZU7d1gYzTRyJ2UDewwyDAU1MNxgvAREGkzenFXktLS9Ce/vjksvlrj0Qfttfz+ev3sNzz939+qW0V3CCILAXl5GRQT7Izs7GMCw3Nzc5OVkkEmEYJpfLi4qKqM5l66S8vLyhoSGqnpGRIRKJkpOTDdWpHYuKiuRyuVQqpSrDw8O5ubnkY6qel5eHYVhWVhbVRp5Pdna2s7MzNQfDMGo+Yw51/i4uLtQc+jrQ59D79a4De930rgO7zjgfag7jeg2tA6NOXS+1Pux1eGHEqlC7t7S0tLS0YBgmk8nIH8lkMvr8Zeskf39/eh3DsPT0dI46JT09nXEV5Pkwrs7f39/f35/eRp5PS0sLfQ59PmMOdf70OfR1YJwP9zqw103vOrDrjPOh5rCfzZXU6etMXhd7HV6UEQYAUhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhECiAGkQKIQaQAYhApgBhvdbtJpVLygbOzM7kp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T06PRaOzt7cVicWpq6vr16+ltc3Nz5JdNVlZWHh4eoaGhcXFx1PdudEqlsqqqSqFQ/P333+Rlp6Wl0Z940ujoaFRUFI7j1tbWXl5eYrH48OHDem/TFRYWjoyM6D351NRUxh1LgiCkUml5efns7KxQKDxz5syWLVv07tvd3X3p0qWenh47O7vk5OSEhARGQ1tbW2lpqd59d+7cGRcXR23m5+drNBq9nadPn7axsSEfNzY2fvjhh0ZGRhs3bvTx8XnttdfCw8P17tXZ2VlRUdHe3v7kyRNLS8u9e/empaVt2rSJ0abRaCorKxsbG/v6+ubm5jw8PCQSSVRUlN6ZLwT+uQUgBv/VCRCDSAHEIFIAsX8BcEjV7cmhMIEAAAAASUVORK5CYII=

This is the data I am getting from delhivery for waybill number barcode image. When I paste it in browser url the image is displayed correctly. But I am not understanding how to add the image in packing slip pdf using zend pdf. I used the following codes, but still it is not showing up properly.

$page->drawText($barcodeImage, 35, ($top -= 30));

$page->drawImage($barcodeImage, $x1, $y1, $x1+30, $y1+15);

$image_barcode = "<img src='".barcodeImage."'>";
$page->drawImage($image_barcode, $x1, $y1, $x1+30, $y1+15);
0

Save barcode image on the server and after that use it.

$data = base64_decode($barcodeImage);

file_put_contents('image.png', $data);

$image_barcode = Zend_Pdf_Image::imageWithPath('image.png');

$page->drawImage($image_barcode,$x1, $y1, $x1+30, $y1+15);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.