I try to print directly with php library php_printer.dll, my problem is that my printer print strange words instead of PDF file.
Here is my code:
Well... your contents consists of all tags and you are giving a text
type output to your printer.
Of course it is going to print like that.
If you want to do a straight print with only the text Write a test 20012-10-24
, then you probably need to create it in another PHP file, read the output with, ie, file_get_contents
and then do your printing with the results received.
Now printing a PDF file is a totally different issue. You can print it via shell execution:
shell_exec( 'lpr /path/to/file/filename.pdf' );
Or with a PHP class found here:
require_once( 'PrintIPP.php' );
$ipp = new PrintIPP();
$ipp->setHost( 'localhost' );
$ipp->setPrinterURI( '/printers/epson' );
$ipp->setData( '/path/to/file/filename.pdf' );
$ipp->printJob();