Skip to content

Instantly share code, notes, and snippets.

@anestan
Last active February 13, 2024 08:04
Show Gist options
  • Save anestan/415e023a479bb3b43cac7c5d2643a42e to your computer and use it in GitHub Desktop.
Save anestan/415e023a479bb3b43cac7c5d2643a42e 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;
?>
@jejeade
Copy link

jejeade commented Feb 13, 2024

apakah bisa pakai printer di luar jaringan?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment