SDK version
9.0.0
PHP version
8.3
What went wrong?
We're using Firefox for our internal shipping application, but it can't seem to open PostNL MyParcel PDF files, due to an Invalid stream error.
It happens both with downloadPdfOfLabels and manually saving the contents from getLabelPdf (downloadPdfOfLabels also uses label_pdf though)
The thing is, the PDF's are displayed just fine in Chrome, but not in Firefox. We're storing/printing/opening a variety of labels from different sources, but I haven't experienced this issue before.
Warning: Invalid stream: "FormatError: Unknown compression method in flate stream: 50, 32" [pdf.worker.mjs:323:13](resource://pdf.js/build/pdf.worker.mjs)
// Please fill in those variables
$person = '';
$street = '';
$number = '';
$numberAdditional = '';
$postalCode = '';
$city = '';
$countryCode = 'NL';
$consignment = (\MyParcelNL\Sdk\Factory\ConsignmentFactory::createByCarrierName('postnl'))
->setApiKey(config('services.my_parcel.api_key'))
->setCountry($countryCode)
->setPerson($person)
->setStreet($street)
->setNumber($number)
->setStreetAdditionalInfo($numberAdditional)
->setPostalCode($postalCode)
->setCity($city);
$consignments = (new \MyParcelNL\Sdk\Helper\MyParcelCollection())
->addConsignment($consignment)
->setPdfOfLabels(false); // A6
$consignments->downloadPdfOfLabels();
Part of our actual code:
$consignment = (ConsignmentFactory::createByCarrierName('postnl'))
->setApiKey(config('services.my_parcel.api_key'))
->setCountry($address->countryCode)
->setPerson($address->getFullName())
->setStreet($address->street)
->setNumber($address->number)
->setPostalCode($address->postalCode)
->setCity($address->city);
// other code
$consignments = (new MyParcelCollection())
->addConsignment($consignment)
->setPdfOfLabels(false); // A6
/** @var AbstractConsignment $consignment */
$consignment = $consignments->first();
$trackingId = $consignment->getBarcode();
$trackingUrl = $consignment->getBarcodeUrl(
barcode: $trackingId,
postalCode: $address->postalCode,
countryCode: $address->countryCode,
);
return new ShippingLabel(
trackingId: $trackingId,
trackingUrl: $trackingUrl,
pdfContents: $consignments->getLabelPdf(),
);
Reproduction steps
- Create a 'postnl' label through the code provided
- Store the contents to a PDF file (e.g. file_put_contents('file.pdf', $consignments->getLabelPdf());
2.1. Alternatively, use downloadPdfOfLabels for the same result
- Open the PDF in Firefox
- Firefox displays a blank PDF and throws an error in the dev tools console
Relevant log output
Additional context
We're using the most recent stable version of Firefox.
SDK version
9.0.0
PHP version
8.3
What went wrong?
We're using Firefox for our internal shipping application, but it can't seem to open PostNL MyParcel PDF files, due to an
Invalid streamerror.It happens both with
downloadPdfOfLabelsand manually saving the contents fromgetLabelPdf(downloadPdfOfLabelsalso useslabel_pdfthough)The thing is, the PDF's are displayed just fine in Chrome, but not in Firefox. We're storing/printing/opening a variety of labels from different sources, but I haven't experienced this issue before.
Warning: Invalid stream: "FormatError: Unknown compression method in flate stream: 50, 32" [pdf.worker.mjs:323:13](resource://pdf.js/build/pdf.worker.mjs)Part of our actual code:
Reproduction steps
2.1. Alternatively, use
downloadPdfOfLabelsfor the same resultRelevant log output
Additional context
We're using the most recent stable version of Firefox.