bangnaga

PHP Cetak Dotmatrix

May 26th, 2015
316
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $tmpdir = sys_get_temp_dir();   # ambil direktori temporary untuk simpan file.
  3. $file =  tempnam($tmpdir, 'ctk');  # nama file temporary yang akan dicetak
  4. $handle = fopen($file, 'w');
  5. $condensed = Chr(27) . Chr(33) . Chr(4);
  6. $bold1 = Chr(27) . Chr(69);
  7. $bold0 = Chr(27) . Chr(70);
  8. $initialized = chr(27).chr(64);
  9. $condensed1 = chr(15);
  10. $condensed0 = chr(18);
  11. $Data  = $initialized;
  12. $Data .= $condensed1;
  13. $Data .= "==========================\n";
  14. $Data .= "|     ".$bold1."HEADER".$bold0."      |\n";
  15. $Data .= "==========================\n";
  16. $Data .= "Hello\n";
  17. $Data .= "row 1\n";
  18. $Data .= "row 2\n";
  19. $Data .= "--------------------------\n";
  20. fwrite($handle, $Data);
  21. fclose($handle);
  22. copy($file, "//localhost/xprinter");  # Lakukan cetak
  23. unlink($file);
  24. ?>
RAW Paste Data