Skip to content

Instantly share code, notes, and snippets.

@andri-sudarmawijaya
Forked from anestan/directprinting.php
Created October 28, 2019 06:30
Show Gist options
  • Save andri-sudarmawijaya/0598dd7376b9458c0b8a86990ba13fc3 to your computer and use it in GitHub Desktop.
Save andri-sudarmawijaya/0598dd7376b9458c0b8a86990ba13fc3 to your computer and use it in GitHub Desktop.
direct printing php dot matrix
<?php
//set printing option to raw
$tmpdir = sys_get_temp_dir(); # ambil direktori temporary untuk simpan file.
$file = tempnam($tmpdir, 'ctk'); # nama file temporary yang akan dicetak
$handle = fopen($file, 'w');
$condensed = Chr(27) . Chr(33) . Chr(4);
$bold1 = Chr(27) . Chr(69);
$bold0 = Chr(27) . Chr(70);
$initialized = chr(27).chr(64);
$condensed1 = chr(15);
$condensed0 = chr(18);
$Data = $initialized;
$Data .= $condensed1;
$Data .= "==========================\n";
$Data .= "| ".$bold1."OFIDZ MAJEZTY".$bold0." |\n";
$Data .= "==========================\n";
$Data .= "Ofidz Majezty is here\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "We Love PHP Indonesia\n";
$Data .= "--------------------------\n";
fwrite($handle, $Data);
fclose($handle);
copy($file, "//192.168.30.29/epsonlx-newwww"); # Lakukan cetak
unlink($file);
return true;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment