PrintBase
  • Product
  • Pricing
  • Docs
  • Resources
PrintBase/Guides/Printing troubleshooting

Receipt printer prints garbage characters

ESC/POS garbage is almost always the code page. The agent does not transcode raw bytes. Encode for the printer before base64.

For Developers whose receipts show garbage

Overview

The agent writes raw bytes to the printer unchanged. If you put UTF-8 Chinese or smart quotes into an ESC/POS buffer, the printer decodes them with its code page and prints garbage. The job can still reach completed.

Match the encoding to the printer. Many Chinese receipt printers want GBK. Many Western printers want a PC code page selected with an ESC t command. Build the bytes in that encoding, then base64 the bytes, not a UTF-8 mis-decode.

A PDF sent as raw is a different failure, INVALID_CONTENT, because of the %PDF- prefix. Garbage text means the bytes were accepted and interpreted wrongly.

Integration steps

  1. 01

    Print a known ASCII test

    ESC @, a line of English, a cut. If that works, the transport is fine.

  2. 02

    Encode the real text

    GBK or the code page in the printer manual. Do this before base64.

  3. 03

    Select the code page in the ticket

    If the manual requires an ESC t sequence, include it after init.

  4. 04

    Do not 'fix' it by sending PDF unless you mean to

    PDF uses the driver and will not honor your cut commands the same way.

Node.js

// Raw bytes you already encoded for the printer
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': orderId,
  },
  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

Completed plus garbage

Status completed means the spooler accepted the bytes. It does not mean the glyphs were right.

Column width

Wrong width looks like wrapping garbage too. 58 mm is about 32 columns, 80 mm about 48.

Questions

Will the API convert UTF-8 to GBK?

No. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.

JSON is UTF-8. Is that the problem?

The outer JSON is UTF-8. The base64 payload inside it should be the printer's bytes.

English works, Chinese does not.

The code page or the Chinese mode is not set. ASCII does not prove the font.

Star TSP100?

It may not want ESC/POS at all. Try a PDF through futurePRNT.

Related guides

  • 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.

  • Print ESC/POS receipts from Python

    Build ESC/POS bytes in Python and send them as raw. The agent does not transcode. Encode text before base64.

  • 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.

Free plan: 100 jobs a month on one computer, no card.

Create a free accountRead the API docs
PrintBase

PrintBase connects your applications to physical printers anywhere - securely, reliably, and in real time.

Product
Receipt PrintingLabel PrintingDashboardDevicesWebhooks
Resources
DocsBlogStatusAPI ReferenceDownloadPrintBase vs PrintNodePrintNode PricingFAQ
Guides
All guidesIntegrationsPrintersCode samplesComparisonsUse casesTroubleshooting
Company
ContactSecurityPrivacy

© 2026 Aveniq Technologies OÜ. All rights reserved. PrintBase is a service of Aveniq Technologies OÜ.

PrivacyTermsRefunds