How to print files using the php printer functions

522 Views Asked by At

Am using WAMP and the printer name is one on the LAN or even on a USB and is present in my devices and printers. This is working when I use "printer_draw_text" to print texts in the code. The problem is just with files. I have the following code which apparently doesnt print files but sends the job to the printer, as it just prints blanks. The file contents are not being printed. Where or what am I missing?

    <?php
    $handle = printer_open("NameHere");
    printer_start_doc($handle, "doc");
    printer_start_page($handle);
    $filename="test.docx";
    $fhandle=fopen($filename, "rb");
    $contents = fread($fhandle, filesize($filename));
    fclose($fhandle);
    printer_set_option($handle, PRINTER_MODE, "RAW");
    printer_write($handle,$contents);
    printer_end_page($handle);
    printer_end_doc($handle);
    printer_close($handle);
    ?>
0

There are 0 best solutions below