Print ESC/POS receipts on an Epson TM-T20III
Send ESC/POS bytes to a TM-T20III as raw, or a PDF if you rely on the Epson driver. 80 mm paper, code page is your responsibility.
For Counters printing receipts on a TM-T20III
Overview
The TM-T20III is an 80 mm Epson thermal receipt printer. Variants differ by USB, Ethernet, or serial, but all of them speak ESC/POS when you talk to the printer language rather than the graphical driver. Send content_type raw with ESC @ at the start and a cut after line feeds.
PrintBase does not ship a driver for this model. The agent prints to a queue the operating system already lists. Raw bytes go straight through: from memory into the Windows spooler, or via lp -o raw on macOS and Linux. PDF jobs go through the OS driver. A PDF marked as raw is rejected with INVALID_CONTENT.
80 mm lines are about 48 columns. The agent does not select the code page. Non-ASCII text must already be in the encoding the printer is set to. A PDF receipt is allowed if you prefer the driver, but then you lose the cut command unless the driver cuts.
Integration steps
- 01
Install the printer in the OS
Use the vendor driver or a raw port until a test page works. The agent cannot see a device the operating system does not list.
- 02
Read the numeric code
GET /v1/printers returns code. That integer is printer_code on POST /v1/print-jobs. The name is for humans.
- 03
Match content_type to the payload
ZPL, EPL, TSPL, and ESC/POS are content_type raw, standard base64. Office documents and driver labels are content_type pdf.
- 04
Key the job to the business id
Reuse one Idempotency-Key per label. A reprint uses a new key. The same key with a different body returns HTTP 409.
- 05
Wait for completed
HTTP 201 means status queued. Poll GET /v1/print-jobs/{id}. Paid plans can subscribe to print_job.completed and print_job.failed only.
Node.js
// TM-T20III ESC/POS receipt
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(receipt).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
Model notes
80 mm lines are about 48 columns. The agent does not select the code page. Non-ASCII text must already be in the encoding the printer is set to. A PDF receipt is allowed if you prefer the driver, but then you lose the cut command unless the driver cuts.
Raw versus PDF on this queue
Raw is not reflowed. On Windows a PDF needs an application that handles PrintTo; the agent error text names Adobe Reader or SumatraPDF as examples. macOS and Linux use lp.
Questions
Do I need Epson Server Direct Print?
No. That feature makes the printer poll a server you host. Here you push a job and the agent prints the OS queue. See the Server Direct Print comparison.
The cutter slices the total.
Add line feeds before GS V. The API does not insert them. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Chinese or accented text is wrong.
Encode for the code page configured on the printer before base64.
Ethernet TM-T20III?
Install it as an OS printer on the agent PC. Do not open that IP to the internet.
Free plan: 100 jobs a month on one computer, no card.