Closed chris102948 closed 3 years ago
You can just output the base64decoded label as a file to save for the user, instead of saving it to disk locally.
A simple solution would be to clean up the cached PDF label files with a cron job. I personally like to keep them around for a short while.
Thank you for your replies. We ended up using TomKriek's solution and output the label together with some additional information as 1 merged PDF using FPDF
I am going to double-check if the library properly supports this after merging the labels. It should be as easy as:
<?php
$postnl = new PostNL(...);
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=postnl-label-923323.pdf");
echo $postnl->getMergedLabels(); // Would prob. require some kind of __toString() implementation
exit;
At this moment we create a shipment and get a PDF label:
However, this will result in a folder with a long list generated PDF's, so it does not look like a proper way to do this. Actually we're looking for a similar approach to the Sendcloud API where a label-URL can be requested through the API: https://docs.sendcloud.sc/api/v2/shipping/#get-a-pdf-label
Is there any similar way to do this with the PostNL API?