function print_prenote2($prenote) { include '../db/config.php'; //$printerList = printer_list(PRINTER_ENUM_LOCAL); if ($printerHandler = printer_open($prenote->printer->name)) { printer_set_option($printerHandler, PRINTER_MODE, "raw"); printer_start_doc($printerHandler, "Prenote " . $prenote->folio); printer_start_page($printerHandler); $fontHeight = 30; $fontWidth = 15; $fontWeight = 200; $firstLine = 80; $lineNumber = 0; $image = $prenote->folio . '.bmp'; $filename = $rootPath . "php\\db\\" . $image; $font = printer_create_font("Arial", $fontHeight, $fontWidth, $fontWeight, false, false, false, 0); printer_select_font($printerHandler, $font); printer_draw_bmp($printerHandler, $filename, 150, 1); printer_draw_text($printerHandler, $prenote->folio, 158, calculateNextLine($lineNumber++)); printer_draw_text($printerHandler, $prenote->clientName, 1, calculateNextLine($lineNumber++)); printer_draw_text($printerHandler, "-----------------------------------------------------------", 1, calculateNextLine($lineNumber++)); $product = $prenote->product; $length = count($product); for ($i = 0; $i < $length; $i++) { printer_draw_text($printerHandler, utf8_decode($product[$i]->Description), 1, calculateNextLine($lineNumber++)); printer_draw_text($printerHandler, $product[$i]->scanCode, 1, calculateNextLine($lineNumber)); printer_draw_text($printerHandler, $product[$i]->unitName, 151, calculateNextLine($lineNumber)); printer_draw_text($printerHandler, $product[$i]->Quantity, 351, calculateNextLine($lineNumber)); $precio_cantidad = $product[$i]->Quantity * $product[$i]->Price; printer_draw_text($printerHandler, '$' . $precio_cantidad, 451, calculateNextLine($lineNumber++)); printer_draw_text($printerHandler, $product[$i]->serialBatch, 1, calculateNextLine($lineNumber++)); } printer_draw_text($printerHandler, "-----------------------------------------------------------", 1, calculateNextLine($lineNumber++)); printer_draw_text($printerHandler, $prenote->narticles, 151, calculateNextLine($lineNumber)); printer_draw_text($printerHandler, '$' . $prenote->total, 351, calculateNextLine($lineNumber++)); printer_draw_text($printerHandler, $prenote->id_employee, 1, calculateNextLine($lineNumber)); printer_draw_text($printerHandler, $prenote->employeeName, 101, calculateNextLine($lineNumber++)); printer_draw_text($printerHandler, $prenote->store_id, 1, calculateNextLine($lineNumber)); printer_draw_text($printerHandler, $prenote->store_name, 101, calculateNextLine($lineNumber++)); printer_draw_text($printerHandler, $prenote->cotizationNumber, 1, calculateNextLine($lineNumber++)); printer_draw_text($printerHandler, $prenote->date, 1, calculateNextLine($lineNumber)); printer_end_page($printerHandler); printer_end_doc($printerHandler); printer_close($printerHandler); return true; } else { return false; } }
public function directPrint($header,$dataArray,$XaxisArray=array(0,30,220,270,340),$Yaxis=30) { $your_printer_name = "EPSON TM-U220 Receipt"; $p=printer_open($your_printer_name); printer_start_doc($p,"Testpage"); printer_start_page($p); $pen = printer_create_pen(PRINTER_PEN_DOT, 1, "000000"); $font = printer_create_font("Draft Condensed",20,6, PRINTER_FW_ULTRALIGHT, false, false, false, 0); printer_select_pen($p, $pen); printer_select_font($p, $font); printer_draw_text($p,"SALVA'S MART @ ESPLANADE",100,0); printer_draw_text($p,"8, RAFFLES AVENUE, #01-08A, Singapore (039802)",50,30); printer_draw_text($p,"Date :".date('d/m/Y'),0,60); printer_draw_text($p,"Time :".date('h:i A'),270,60); printer_draw_line($p, 0,90, 500, 90); printer_draw_text($p,$header,0,110); $noofRows=count($dataArray); $yStart=140; for($i=0; $i<$noofRows; $i++){ $y=($i*$Yaxis)+$yStart; $tdCount=count($dataArray[0]); for($j=0; $j<$tdCount; $j++){ $x=$XaxisArray[$j]; printer_draw_text($p,$dataArray[$i][$j],$x,$y); } } printer_draw_text($p,"Thank You!!! Visit Again!!!",100,$y+50); printer_delete_font($font); printer_delete_pen($pen); printer_end_page($p); printer_end_doc($p); printer_close($p); }
function printTest() { //Tracert HP817ACF //$handle = printer_open() ;// Gets the default printer and prints to it. //$handle = printer_open('\\\\192.168.1.247\\HP817ACF'); $handle = printer_open('HP Deskjet 3540 series (Network)'); // Gets the printer by name, to get printer name, go to devices and printers option, select a printer on the network , you will see the name on top //HP Deskjet 3540 series (Network) print_r($handle); printer_start_doc($handle, "My Document"); printer_start_page($handle); $font = printer_create_font("Arial", 72, 48, 400, false, false, false, 0); printer_select_font($handle, $font); printer_draw_text($handle, "test", 10, 10); printer_delete_font($font); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); //$fh = fopen("filename.ext", "rb"); // $content = fread($fh, filesize("filename.ext")); //fclose($fh); /*printer_set_option($handle, PRINTER_MODE, "text"); printer_write($handle, "TEXT To print"); printer_close($handle); */ }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> Imprimir un archivo <a href="c:\imgsspd\codbarras.exe">Imprimir</a> <?php //$handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $font = printer_create_font("Arial", 72, 48, 400, false, false, false, 0); printer_select_font($handle, $font); printer_draw_text($handle, "test", 10, 10); printer_delete_font($font); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); ?> </body> </html>
function print_line_win($value, $dest) { $debug = _FUNCTION_ . ' - Windows Printing to dest ' . $dest . ' - line ' . $value . ' ' . "\n"; debug_msg(__FILE__, __LINE__, $debug); $title = 'SmartRestaurant'; $handle = printer_open(stripslashes($dest)); if (!$handle) { return ERR_COULD_NOT_OPEN_PRINTER; } $debug = __FUNCTION__ . ' - Windows Printing to dest ' . $dest . ' - line ' . $value . ' ' . "\n"; debug_msg(__FILE__, __LINE__, $debug); printer_set_option($handle, PRINTER_MODE, "RAW"); $value = stri_replace("\n", "\n\r", $value); printer_start_doc($handle, $title); printer_start_page($handle); if (!printer_write($handle, $value)) { return ERR_PRINTING_ERROR; } printer_end_page($handle); printer_end_doc($handle); printer_close($handle); return 0; }
public function enviar_a_impresora($data = array()) { // Envia documento a impresora via printer.dll (Windows) $this->impresora = isset($data['impresora']) ? $data['impresora'] : $this->impresora; $this->logo = isset($data['logo']) ? $data['logo'] : ''; $this->contenido = isset($data['contenido']) ? $data['contenido'] : ''; $this->formato = isset($data['formato']) ? $data['formato'] : ''; $this->codebar = isset($data['codebar']) ? $data['codebar'] : ''; $this->codeqr = isset($data['codeqr']) ? $data['codeqr'] : ''; if ($this->formato) { // Lee archivo y extrae contenido para enviarlo a la impresora $this->fh = fopen($this->contenido, "r"); while (!feof($this->fh)) { $this->texto[] = fgets($this->fh); } fclose($this->fh); $isfile = true; } else { $this->texto = $this->contenido; } if ($this->impresora && $this->texto) { if ($this->ph = printer_open($this->impresora)) { #Crea manejador de impresora #Contrucción de documento en impresora // Inicio de doc y page printer_start_doc($this->ph); printer_start_page($this->ph); // Set print mode to RAW and send PDF to printer printer_set_option($this->ph, PRINTER_MODE, "RAW"); $salto_linea = 0; if ($this->formato) { if (file_exists($this->logo)) { // Imagen BMP - Logo printer_draw_bmp($this->ph, $this->logo, $this->var['ticket']['ticket_logo_x'], $this->var['ticket']['ticket_logo_y'], $this->var['ticket']['ticket_logo_w'], $this->var['ticket']['ticket_logo_h']); $salto_linea = $this->var['ticket']['ticket_logo_salto']; } // Crear formato de texto $estilo = printer_create_font($this->var['ticket']['ticket_formato_font'], $this->var['ticket']['ticket_formato_h'], $this->var['ticket']['ticket_formato_w'], $this->var['ticket']['ticket_formato_font_w'], $this->var['ticket']['ticket_formato_font_italic'], $this->var['ticket']['ticket_formato_font_underline'], $this->var['ticket']['ticket_formato_font_strikeout'], $this->var['ticket']['ticket_formato_font_orientation']); printer_select_font($this->ph, $estilo); // Contenido if ($isfile) { $txtArray = $this->texto; for ($i = 0; $i < count($txtArray); $i++) { printer_draw_text($this->ph, $txtArray[$i], $this->var['ticket']['ticket_contenido_x'], $salto_linea); #Izq; Alto $salto_linea += $this->var['ticket']['ticket_contenido_salto']; } } else { printer_draw_text($this->ph, $this->texto, $this->var['ticket']['ticket_contenido_x'], $salto_linea); } // Eliminar formato de texto printer_delete_font($estilo); // Codigo de Barras if ($this->codebar && file_exists($this->codebar)) { printer_draw_bmp($this->ph, $this->codebar, $this->var['ticket']['ticket_barscode_x'], $salto_linea, $this->var['ticket']['ticket_barscode_w'], $this->var['ticket']['ticket_barscode_h']); $salto_linea += $this->var['ticket']['ticket_barscode_salto']; } // Codigo QR if ($this->codeqr && file_exists($this->codeqr)) { printer_draw_bmp($this->ph, $this->codeqr, $this->var['ticket']['ticket_qrcode_x'], $salto_linea, $this->var['ticket']['ticket_qrcode_w'], $this->var['ticket']['ticket_qrcode_h']); $salto_linea += $this->var['ticket']['ticket_qrcode_salto']; } // Footer if ($this->footer) { $estilo = printer_create_font($this->var['ticket']['ticket_formato_footer_font'], $this->var['ticket']['ticket_formato_footer_h'], $this->var['ticket']['ticket_formato_footer_w'], $this->var['ticket']['ticket_formato_footer_font_w'], $this->var['ticket']['ticket_formato_footer_font_italic'], $this->var['ticket']['ticket_formato_footer_font_underline'], $this->var['ticket']['ticket_formato_footer_font_strikeout'], $this->var['ticket']['ticket_formato_footer_font_orientation']); printer_select_font($this->ph, $estilo); printer_draw_text($this->ph, date('Y-m-d H:i:s'), $this->var['ticket']['ticket_footer_x'], $salto_linea); printer_delete_font($estilo); } } else { printer_write($this->ph, $this->texto); #texto sin formato } // Fin de documento y página printer_end_page($this->ph); printer_end_doc($this->ph); // Cierra archivo y envía a imprimir printer_close($this->ph); $this->respuesta = true; } } return $this->respuesta; }