user3688154
user3688154

Reputation: 1

Esc P Brother QL720NW

I'm trying to print from a php script to the thaermal printer in subject with ESC/P language. Everything is ok when i try to normal print text, the problem is that i'm not able to set font size or, generally, formatting options. For example reading the manual i found that if i want to set font size i have to use these codes:

  • [ASCII] ESC X m nL nH
  • [Decimal] 27 88 m nL nH
  • [Hexadecimal] 1B 58 m nL nH

So I've sent comands in this way:

fwrite ( $fp, "\x1B \x40" );
        fwrite ( $fp, "\x1B \x58 \x00 \x30 \x80" );
        fwrite ( $fp, $stringToPrint );//"\x72 \x20 \x73 \x69 \x64 \x65");
        fwrite ( $fp, "\x0C" );

But it prints simpy the text and number instead of understanding the format options. Where i'm wrong???

Upvotes: 0

Views: 1033

Answers (2)

Crocus
Crocus

Reputation: 11

There is a whole lot of information missing from the manual on what sequence to use for which commands in order to get things to actually work. I have been working on this for weeks, and I'm an experienced developer.

The "SDK" wants you to go into P-touch Editor, create templates there, and then send your data with code you develop.

It seems they don't want you to actually use ESC/P on its own. That is actually their proprietary version of Epson's ESC/POS, and is NOT an extension.

Brother tech support refuses to help with anything related to ESC/P, which is a bit of a head-scratcher, considering they went to the trouble of making us aware of its existence, writing a "Command Reference" (which does not explain a lot of things any developer needs to know), and posting a couple of YouTube videos (none of which you will find helpful).

Your best bet is to look at the SDK and see how Brother wants you to do this.

If you need to, you can use a command line utility called "senddat.exe" which Epson wrote to feed data directly to a printer (be sure to use the "script" command line option). Unlike the rawspl.exe that Bob (from the Youtube Brother videos) tells you to use, but can't be found ANYWHERE, senddat is easy to find, and free.

I'm going to try to get Brother's attention at the corporate level, to see if they will allocate any resources to making ESC/P a functional, useable and documented language. I will update if I have any success.

Upvotes: 0

mike42
mike42

Reputation: 1688

As I don't have the same printer, I can't comment on whether this command will do what you expect, but it does appear that you are including spaces between each byte of the command, which is not correct ESC/P2.

The convention in the reference seems to be to include a hex and decimal code for bytes that are meant to be sent, while spacing is just for readability.

A snippet which follows the standard for these commands would be-

<?php

// Initialize printer
$fp = fopen("/dev/usb/lp0", "wb+");
fwrite ( $fp, "\x1B\x40" ); // ESC @

// Select font by pitch and point
$m = 0; // No change in pitch
$nL = 48; // Assuming these point options are what you intend?
$nH = 128;
fwrite ( $fp, "\x1B\x58" . chr($m) . chr($nL) . chr($nH)); // ESC X m nL nH

// Print text
$stringToPrint = "Hello\n";
fwrite ( $fp, $stringToPrint );

// Form feed
fwrite ( $fp, "\x0C" ); // FF

Upvotes: 2

Related Questions