print directly from iis using php aplication to printer through server not browser to a shared printer
after 4 weeks I find a solution.
this is a way to use a shared printer.
use mike42 escpos github plugin.
require 'vendor/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\CapabilityProfile;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
$connector = new WindowsPrintConnector("smb://computername/printername");
$printer = new Printer($connector);
$printer -> text("hello world");
$printer -> text("\n");
$printer -> text("\n");
$printer -> text("hello again");
$printer -> cut();
$printer -> close();
printing over network from PHP app
You could use the LPR Printer class from here:
http://www.phpclasses.org/package/2540-PHP-Abstraction-for-printing-documents.html
Example:
<?php
include("PrintSend.php");
include("PrintSendLPR.php");
$lpr = new PrintSendLPR();
$lpr->setHost("10.0.0.17"); //Put your printer IP here
$lpr->setData("C:\\wampp2\\htdocs\\print\\test.txt"); //Path to file, OR string to print.
$lpr->printJob("someQueue"); //If your printer has a built-in printserver, it might just accept anything as a queue name.
?>
Printing data to printer using PHP
For anyone who is having the same trouble, I figured out I can simply push the data using socket programming as follows. The ip address below is my printer's ip address. You can telnet into your printer to make sure the connection works beforehand if you'd like.
if(isset($_POST['order'])){
$print_output= $_POST['order'];
}
try
{
$fp=pfsockopen("192.168.1.33", 9100);
fputs($fp, $print_output);
fclose($fp);
echo 'Successfully Printed';
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
Related Topics
Ffmpeg Mamp "Dyld: Library Not Loaded" Error
Call-Time Pass-By-Reference Has Been Removed
Check If SQL Row Exists with PHP
How to Use a Class Method as a Callback Function
Convert Windows Timestamp to Date Using PHP on a Linux Box
How to Get Content of Remote HTML Page
Check If Youtube and Vimeo-Clips Are Valid
How to Run a Whois Lookup with PHP or Python
PHP Sum Variable in While Loop
Php: Require Path Does Not Work for Cron Job
Zend Framework 2 Routing Subdomains to Module
How to Determine the Length (In Pixels) of a String Being Rendered on a Web Page
Uploading Image from Android to PHP Server
Converting Between Timezones in PHP
.Htaccess Rewrite: Subdomain as Get Var and Path as Get Var