Send raw ZPL or PDF?
Use ZPL or TSPL when the printer speaks it and you draw the label. Use PDF when you already have a document or the printer is a driver device.
For Developers choosing content_type
Overview
content_type has two values: pdf and raw. Raw is for printer languages such as ZPL, EPL, ESC/POS, and TSPL. PDF is for documents and for printers that only work through a driver, including many Rollo, DYMO, and Brother models.
The agent rejects PDF, PNG, JPEG, and ZIP payloads marked as raw. On Linux, raw is sent with lp -o raw. On Windows, raw is spooled from memory. PDF on Windows needs a PDF application that can print to a named queue.
A single simple ZPL label can have copies folded into ^PQ. PDF copies are the copies field and the driver. Do not convert between the two unless you have a reason.
Integration steps
- 01
If the file starts with %PDF
Send content_type pdf. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 02
If the file starts with ^XA or a TSPL SIZE command
Send raw. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 03
If you are unsure the printer speaks that language
Print one raw test locally before you automate it. Otherwise use PDF.
- 04
Match size
Dots for commands, page size for PDF. The API does not convert units.
Node.js
// Raw ZPL when you draw the label
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': labelId,
},
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
^PQ folding
One ^XA and one ^XZ, copies greater than 1, and no existing ^PQ, ^SN, or ^SF: the agent inserts ^PQ and prints the data once.
Driver scaling
PDF barcodes fail when the driver scales the page. Commands avoid that. The agent prints only what you send; it does not fetch the document from the platform for you.
Questions
Can I send HTML?
No. pdf or raw only. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Can I send a PNG?
Not as a content type. Put the image inside a PDF or a printer language.
EPL? in this setup
Raw, if the printer is in EPL mode. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Which one scans better?
Commands, when the printer supports them. A correctly sized PDF is the right choice on a driver-only printer.
Free plan: 100 jobs a month on one computer, no card.