Why a PDF barcode will not scan on a thermal printer
Thermal heads print crisp barcodes from ZPL or TSPL. A PDF barcode is a picture the driver scales. Send raw commands when the printer speaks them.
For People whose thermal barcodes will not scan
This page in another language: 中文
Overview
A PDF barcode is pixels. The driver may scale the page to the roll, and the thermal head then prints a fuzzy module. Scanners reject it. ZPL ^BC or ^BQ, or TSPL BARCODE, asks the printer to draw the symbol at a module width it can hold.
If the carrier gave you a finished 4 by 6 PDF, do not redraw it badly. Print that PDF at the real page size with scaling off. Redraw only when you own the data and the printer speaks a command language.
Sending the PDF bytes with content_type raw fails closed: the agent rejects a leading %PDF- as INVALID_CONTENT. That error is useful. It means you marked a document as commands.
Integration steps
- 01
Check the file
If it starts with %PDF, it is a document. Use content_type pdf and the correct page size.
- 02
If you own the data and have a Zebra or TSC
Emit ZPL or TSPL and send raw. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 03
Turn off fit-to-page
Driver scaling is a common reason a good PDF scans badly. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 04
Scan a sample before the batch
One bad setting wastes a roll. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
Node.js
// ZPL barcode instead of a scaled PDF
const res = await fetch('https://api.printbase.cloud/v1/print-jobs', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRINTBASE_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': idempotencyKey,
},
body: JSON.stringify({
printer_code: Number(process.env.PRINTER_CODE),
content_type: 'raw',
content: Buffer.from(zpl,'utf8').toString('base64'),
copies: 1,
}),
});
if (!res.ok) throw new Error(`PrintBase ${res.status}: ${await res.text()}`);
const job = await res.json();
// { id: "job_abc", status: "queued" }
Details for this setup
INVALID_CONTENT
PDF, PNG, JPEG, and ZIP magic are rejected when content_type is raw. The agent prints only what you send; it does not fetch the document from the platform for you.
DPI
Command languages use dots. 203 dpi is about 8 dots per millimetre. A 300 dpi head needs different coordinates.
Questions
Should every label be ZPL?
No. DYMO, Brother, Rollo, and many shipping printers want PDF through their driver.
Can the API rasterize ZPL to PDF?
No. It transports bytes. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
The PDF looks sharp on a laser and fuzzy on thermal.
The head and the scaling differ. Fix size or switch to commands.
Copies of a bad barcode?
copies will repeat the bad barcode. Fix the file first. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Free plan: 100 jobs a month on one computer, no card.