Label Printing
Help with generating, decoding, and printing DPD shipping labels.
Labels in the API response
A successful shipment creation returns each label as a Base64-encoded PDF string in success[].label.
{
"success": [
{
"id": 1,
"parcelNumber": "05305000123456",
"label": "JVBERi0xLjQKJeLjz9MK..."
}
]
}
Decoding and saving the label
Shell:
echo "JVBERi0xLjQK..." | base64 --decode > label.pdf
JavaScript (browser):
function downloadLabel(base64Label, parcelNumber) {
const bytes = atob(base64Label);
const array = new Uint8Array(bytes.length);
for (let i = 0; i < bytes.length; i++) array[i] = bytes.charCodeAt(i);
const blob = new Blob([array], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `label-${parcelNumber}.pdf`;
a.click();
URL.revokeObjectURL(url);
}
Java:
byte[] pdfBytes = Base64.getDecoder().decode(labelBase64);
Files.write(Path.of("label-" + parcelNumber + ".pdf"), pdfBytes);
Choosing the right label format
Set printOptions.labelFormat in your shipment request:
| Format | Value | Use case |
|---|---|---|
| A4 | "A4" | Standard office printers. Up to 4 labels per sheet — control position with labelStartPosition (1–4) |
| Thermal / A6 | "A6" | Direct thermal label printers (Zebra, Citizen, etc.) |
"printOptions": {
"labelFormat": "A6"
}
Multiple labels on one A4 sheet
When printing multiple shipments, pack them onto A4 sheets to save paper:
[
{ ..., "printOptions": { "labelFormat": "A4", "labelStartPosition": 1 } },
{ ..., "printOptions": { "labelFormat": "A4", "labelStartPosition": 2 } },
{ ..., "printOptions": { "labelFormat": "A4", "labelStartPosition": 3 } },
{ ..., "printOptions": { "labelFormat": "A4", "labelStartPosition": 4 } }
]
Label is blank or corrupted
Cause 1: Base64 decoding error — extra whitespace or line breaks in the string.
Fix: Strip all whitespace before decoding:
const cleanBase64 = base64String.replace(/\s+/g, '');
Cause 2: PDF viewer compatibility.
Fix: Try opening the PDF in a different viewer. Labels are valid PDF 1.4+ files.
Cause 3: Thermal printer DPI mismatch.
Fix: Configure your printer to 203 or 300 DPI (check your printer's manual). The label format is designed for standard DPD thermal printers.
Still having issues?
Provide the following to DPD support:
tracingIdfrom the API responseparcelNumberof the affected label- Label format used (
A4/A6) - Your printer model and driver version