Bradleyb
Bradleyb

Reputation: 31

Can I send a ESC d command to a POS printer from perl?

I have a Star TSP100 printer and I'm having few problems with it really.

My problem is that I'm not as familiar with programming as I should be - but I'm learning!

The programmers reference for the Star printer says that if I send a ESC d to the printer - that will activate the built-in cutter - which I would like to do very much.

My problem is that I have no idea how to send an escape code like that from within Perl - if it's even possible.

I really appreciate any advice on this one.

Upvotes: 3

Views: 2009

Answers (3)

Shantanu Bhadoria
Shantanu Bhadoria

Reputation: 14520

You can use my module Printer::Thermal from CPAN

https://metacpan.org/pod/Printer::Thermal

$printer = Printer::Thermal->new(serial_device_path=$path);
$printer->write("\x1d" . 'd'); # \x1d is ESC
$printer->print;

BTW esc d is used for print and feed lines

You can use the inbuilt function cutpaper to make things simpler

$printer->cutpaper;
$printer->print;

Upvotes: 0

hobbs
hobbs

Reputation: 240284

Escape is just a character; it can be written (among other things) as "\e" or "\033". So assuming you have a handle open to the printer device, all you need is to print $fh "\ed".

Upvotes: 6

Hernán
Hernán

Reputation: 4587

http://www.rhinocerus.net/forum/lang-clipper-visual-objects/600098-lowlevel-printing-esc-codes-sending-printer-vista.html#post2414259

It's written in Clipper but fairly easy to understand since it uses the standard Windows Printing API, callable in 99% of Win32 programming languages.b

Upvotes: 0

Related Questions